From 02409bfbe15f22fc3b5dccadabfd860a660a49d9 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Sat, 11 Oct 2025 10:37:14 +0800
Subject: [PATCH] feat: 名称修改

---
 src/views/resource/attach.vue |  245 ++++++++++++++++++++++++++-----------------------
 1 files changed, 130 insertions(+), 115 deletions(-)

diff --git a/src/views/resource/attach.vue b/src/views/resource/attach.vue
index fc2bf4d..fe1f5c6 100644
--- a/src/views/resource/attach.vue
+++ b/src/views/resource/attach.vue
@@ -1,49 +1,18 @@
 <template>
   <basic-container>
-    <avue-crud
-      :option="option"
-      :table-loading="loading"
-      :data="data"
-      v-model:page="page"
-      :permission="permissionList"
-      :before-open="beforeOpen"
-      v-model="form"
-      ref="crud"
-      @row-del="rowDel"
-      @search-change="searchChange"
-      @search-reset="searchReset"
-      @selection-change="selectionChange"
-      @current-change="currentChange"
-      @size-change="sizeChange"
-      @refresh-change="refreshChange"
-      @on-load="onLoad"
-    >
+    <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" :permission="permissionList"
+      :before-open="beforeOpen" v-model="form" ref="crud" @row-del="rowDel" @search-change="searchChange"
+      @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
+      @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
       <template #menu-left>
-        <el-button
-          type="primary"
-          plain
-          v-if="permission.attach_upload"
-          icon="el-icon-upload"
-          @click="handleUpload"
-          >上 传
+        <el-button type="primary" plain v-if="permission.attach_upload" icon="el-icon-upload" @click="handleUpload">上 传
         </el-button>
-        <el-button
-          type="danger"
-          icon="el-icon-delete"
-          plain
-          v-if="permission.attach_delete"
-          @click="handleDelete"
-          >删 除
+        <el-button type="danger" icon="el-icon-delete" plain v-if="permission.attach_delete" @click="handleDelete">删 除
         </el-button>
       </template>
       <template #menu="scope">
-        <el-button
-          type="primary"
-          text
-          icon="el-icon-download"
-          v-if="permission.attach_download"
-          @click="handleDownload(scope.row)"
-          >下载
+        <el-button type="primary" text icon="el-icon-download" v-if="permission.attach_download"
+          @click="handleDownload(scope.row)">下载
         </el-button>
       </template>
       <template #attachSize="{ row }">
@@ -58,12 +27,12 @@
 </template>
 
 <script>
-import { getList, getDetail, remove } from '@/api/resource/attach';
-import { mapGetters } from 'vuex';
-import func from '@/utils/func';
+import { getList, getDetail, removeAttachAndData } from '@/api/resource/attach'
+import { mapGetters } from 'vuex'
+import func from '@/utils/func'
 
 export default {
-  data() {
+  data () {
     return {
       form: {},
       query: {},
@@ -76,17 +45,18 @@
       attachBox: false,
       selectionList: [],
       option: {
-        height: 'auto',
-        calcHeight: 32,
         tip: false,
         searchShow: true,
         searchMenuSpan: 6,
         border: true,
         index: true,
         viewBtn: true,
-        grid: true,
+        // grid: true,
         selection: true,
         dialogClickModal: false,
+
+        height: 'auto',
+        calcHeight: 20,
         column: [
           {
             label: '附件地址',
@@ -102,7 +72,6 @@
           {
             label: '附件域名',
             prop: 'domainUrl',
-            search: true,
             rules: [
               {
                 required: true,
@@ -115,6 +84,7 @@
             label: '附件名称',
             prop: 'name',
             search: true,
+            searchSpan: 4,
             rules: [
               {
                 required: true,
@@ -127,6 +97,7 @@
             label: '附件原名',
             prop: 'originalName',
             search: true,
+            searchSpan: 4,
             rules: [
               {
                 required: true,
@@ -138,6 +109,9 @@
           {
             label: '附件拓展名',
             prop: 'extension',
+            search: true,
+            searchSpan: 4,
+            searchLabelWidth: 95,
             rules: [
               {
                 required: true,
@@ -157,6 +131,34 @@
                 trigger: 'blur',
               },
             ],
+          },
+          {
+            label: '创建日期',
+            prop: 'createTime'
+          },
+          {
+            label: '创建日期',
+            prop: 'daterange',
+            type: 'daterange',
+            search: true,
+            searchRange: true,
+            searchSpan: 6,
+            format: 'YYYY-MM-DD',
+            valueFormat: 'YYYY-MM-DD',
+            startPlaceholder: '开始时间',
+            endPlaceholder: '结束时间',
+            viewDisplay: false,
+            hide: true,
+            rules: [
+              {
+                required: true,
+                message: '请选择操作时间',
+                trigger: 'blur',
+              },
+            ],
+              change: (value) => {
+               this.searchChange({ ...this.query,daterange:value.value}, () => {});
+            }
           },
         ],
       },
@@ -180,127 +182,140 @@
           },
         ],
       },
-    };
+    }
   },
   computed: {
-    func() {
-      return func;
+    func () {
+      return func
     },
     ...mapGetters(['permission']),
-    permissionList() {
+    permissionList () {
       return {
         addBtn: false,
         editBtn: false,
         viewBtn: false,
         delBtn: this.validData(this.permission.attach_delete, false),
-      };
+      }
     },
-    ids() {
-      let ids = [];
+    ids () {
+      let ids = []
       this.selectionList.forEach(ele => {
-        ids.push(ele.id);
-      });
-      return ids.join(',');
+        ids.push(ele.id)
+      })
+      return ids.join(',')
     },
   },
   methods: {
-    handleUpload() {
-      this.attachBox = true;
+    handleUpload () {
+      this.attachBox = true
     },
-    uploadAfter(res, done, loading, column) {
-      window.console.log(column);
-      this.attachBox = false;
-      this.refreshChange();
-      done();
+    uploadAfter (res, done, loading, column) {
+      window.console.log(column)
+      this.attachBox = false
+      this.refreshChange()
+      done()
     },
-    handleDownload(row) {
-      window.open(`${row.link}`);
+    handleDownload (row) {
+      window.open(`${row.link}`)
     },
-    rowDel(row) {
-      this.$confirm('确定将选择数据删除?', {
+    rowDel (row) {
+      this.$confirm('确定将选择数据及对应的文件删除?', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning',
       })
         .then(() => {
-          return remove(row.id);
+          return removeAttachAndData(row.id)
         })
         .then(() => {
-          this.onLoad(this.page);
+          this.onLoad(this.page)
           this.$message({
             type: 'success',
             message: '操作成功!',
-          });
-        });
+          })
+        })
     },
-    handleDelete() {
+    handleDelete () {
       if (this.selectionList.length === 0) {
-        this.$message.warning('请选择至少一条数据');
-        return;
+        this.$message.warning('请选择至少一条数据')
+        return
       }
-      this.$confirm('确定将选择数据删除?', {
+      this.$confirm('确定将选择数据及对应的文件删除?', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning',
       })
         .then(() => {
-          return remove(this.ids);
+          return removeAttachAndData(this.ids)
         })
         .then(() => {
-          this.onLoad(this.page);
+          this.onLoad(this.page)
           this.$message({
             type: 'success',
             message: '操作成功!',
-          });
-          this.$refs.crud.toggleSelection();
-        });
+          })
+          this.$refs.crud.toggleSelection()
+        })
     },
-    beforeOpen(done, type) {
+    beforeOpen (done, type) {
       if (['edit', 'view'].includes(type)) {
         getDetail(this.form.id).then(res => {
-          this.form = res.data.data;
-        });
+          this.form = res.data.data
+        })
       }
-      done();
+      done()
     },
-    searchReset() {
-      this.query = {};
-      this.onLoad(this.page);
+    searchReset () {
+      this.query = {}
+      this.onLoad(this.page)
     },
-    searchChange(params, done) {
-      this.query = params;
-      this.page.currentPage = 1;
-      this.onLoad(this.page, params);
-      done();
+    searchChange (params, done) {
+      this.query = params
+      this.page.currentPage = 1
+      this.onLoad(this.page, params)
+      done()
     },
-    selectionChange(list) {
-      this.selectionList = list;
+    selectionChange (list) {
+      this.selectionList = list
     },
-    selectionClear() {
-      this.selectionList = [];
-      this.$refs.crud.toggleSelection();
+    selectionClear () {
+      this.selectionList = []
+      this.$refs.crud.toggleSelection()
     },
-    currentChange(currentPage) {
-      this.page.currentPage = currentPage;
+    currentChange (currentPage) {
+      this.page.currentPage = currentPage
     },
-    sizeChange(pageSize) {
-      this.page.pageSize = pageSize;
+    sizeChange (pageSize) {
+      this.page.pageSize = pageSize
     },
-    refreshChange() {
-      this.onLoad(this.page, this.query);
+    refreshChange () {
+      this.onLoad(this.page, this.query)
     },
-    onLoad(page, params = {}) {
-      this.loading = true;
-      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
-        const data = res.data.data;
-        this.page.total = data.total;
-        this.data = data.records;
-        this.loading = false;
-        this.selectionClear();
-      });
+    onLoad (page, params = {}) {
+      const { daterange } = this.query
+      let values = {
+        ...params,
+        ...this.query,
+      }
+      if (daterange) {
+        values = {
+          ...values,
+          startTime: daterange[0],
+          endTime: daterange[1],
+        }
+        values.daterange = null
+      }
+      this.loading = true
+      getList(page.currentPage, page.pageSize, values).then(res => {
+        const data = res.data.data
+        this.page.total = data.total
+        this.data = data.records
+        this.loading = false
+        this.selectionClear()
+      })
     },
   },
-};
+}
 </script>
 
-<style></style>
+<style scoped lang="scss"></style>

--
Gitblit v1.9.3