瀏覽代碼

Merge branch 'master' of http://git.cc-lotus.info/laboratory/ruoyi-project

guhongwei 3 年之前
父節點
當前提交
f5c1ca243a

+ 45 - 11
java代码/ruoyi-ui/src/components/free/excel-view.vue

@@ -4,8 +4,15 @@
       <el-col :span="12">
         <div id="excel" />
       </el-col>
-      <el-col :span="12">
-        extInfo
+      <el-col v-if="viewRowCol" :span="10">
+        <el-row>
+          <el-col :span="24" :xs="0" style="padding:20px">
+            当前内容说明内容为:<br>{{ getCellContent() }}
+          </el-col>
+          <el-col :span="24">
+            <el-input v-model="tip" type="textarea" :autosize="{ minRows: 30, maxRows: 30}" />
+          </el-col>
+        </el-row>
       </el-col>
     </el-row>
   </div>
@@ -30,6 +37,9 @@ export default {
   data: function() {
     return {
       sheet: undefined,
+      // 点击的框体,只针对数据中带有from作用
+      viewRowCol: undefined,
+      tip: undefined,
       excelOptions: {
         mode: 'edit',
         view: this.view,
@@ -44,6 +54,18 @@ export default {
           }
         }
       }
+
+    }
+  },
+  watch: {
+    tip: {
+      handler(val) {
+        if (this.viewRowCol) {
+          const tip = _.clone(val)
+          // eslint-disable-next-line vue/no-mutating-props
+          this.data.rows[_.head(this.viewRowCol)].cells[_.last(this.viewRowCol)].tip = tip
+        }
+      }
     }
   },
   created() {},
@@ -54,23 +76,35 @@ export default {
     init() {
       if (this.sheet) return
       this.sheet = new Spreadsheet('#excel', this.excelOptions).loadData(this.data).change((d) => {
-        console.log(d)
       }) // load data
       this.sheet.on('cell-selected', (cell, ri, ci) => {
         // data.rows[ri].cells[ci]可以确定到指定单元格
-        console.log(cell)
-        console.log(ri)
-        console.log(ci)
-      })
-      this.sheet.on('cell-edited', (text, ri, ci) => {
-        console.log(text)
-        console.log(ri)
-        console.log(ci)
+        if (_.isArray(this.viewRowCol)) {
+          // 说明之前有,需要保存起来后再换当前的
+          const tip = _.clone(this.tip)
+          // eslint-disable-next-line vue/no-mutating-props
+          this.data.rows[_.head(this.viewRowCol)].cells[_.last(this.viewRowCol)].tip = tip
+          this.viewRowCol = undefined
+          this.tip = undefined
+        }
+        if (_.get(cell, 'from')) {
+          this.tip = cell.tip
+          this.viewRowCol = [ri, ci]
+        }
       })
     },
     reRender(excelData) {
       this.sheet.loadData(excelData)
       this.sheet.reRender()
+    },
+    getCellPosition() {
+      const [row, col] = this.viewRowCol
+      const number = row + 65
+      return `${String.fromCharCode(number)}${col}`
+    },
+    getCellContent() {
+      const text = _.get(this.data, `rows[${_.head(this.viewRowCol)}].cells[${_.last(this.viewRowCol)}].text`)
+      return text || ''
     }
   }
 }

+ 4 - 0
java代码/ruoyi-ui/src/store/template.js

@@ -30,6 +30,10 @@ const actions = {
   async delete({ commit }, payload) {
     const res = await this.$axios.$delete(`${api.interface}/${payload}`)
     return res
+  },
+  async toUse({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}/toUse/${payload}`)
+    return res
   }
 }
 export default {

+ 40 - 9
java代码/ruoyi-ui/src/views/merits/template/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div id="index">
     <template>
-      <list-view v-show="view==='list'" style="padding:20px" @toAdd="toAdd" />
+      <list-view v-show="view==='list'" ref="list" style="padding:20px" @toAdd="toAdd" @toEdit="toEdit" />
     </template>
     <template v-if="view==='detail'">
       <el-row style="padding:20px" type="flex">
@@ -19,7 +19,12 @@
           </el-upload>
         </el-col>
       </el-row>
-      <excel-view ref="excelView" v-model="data" :view="viewStyle" />
+      <el-form label-position="right" label-width="120px">
+        <el-form-item label="模板标题">
+          <el-input v-model="info.title" />
+        </el-form-item>
+        <excel-view ref="excelView" v-model="data" :view="viewStyle" />
+      </el-form>
     </template>
   </div>
 </template>
@@ -40,28 +45,54 @@ export default {
       view: 'list',
       data: {},
       viewStyle: {
-        height: () => document.documentElement.clientHeight - 200,
+        height: () => document.documentElement.clientHeight - 250,
         width: () => 800
-      }
+      },
+      info: {}
     }
   },
   created() {},
   methods: {
-    ...mapActions({}),
+    ...mapActions(['create', 'fetch', 'update']),
     toAdd() {
+      this.returnData()
       this.view = 'detail'
     },
-    async toEdit() {
-      // 请求数据,修改
-      console.log('line 45 in function:toEdit')
+    async toEdit(id) {
+      this.returnData()
+      // 请求数据,修改;将excel放到data里,其他的放到别地方
+      const res = await this.fetch(id)
+      if (this.$checkRes(res)) {
+        const { excel = {}, ...info } = res.data
+        this.$set(this, `data`, excel)
+        this.$set(this, `info`, info)
+        this.view = 'detail'
+      }
     },
     async toSave() {
       const dup = _.cloneDeep(this.data)
-      console.log(dup)
+      const info = _.cloneDeep(this.info)
+      info.excel = dup
+      let res
+      if (info._id) {
+        // update
+        res = await this.update(info)
+      } else {
+        res = await this.create(info)
+      }
+      if (this.$checkRes(res, res.msg, res.msg || '操作失败')) {
+        this.returnList()
+        this.returnData()
+        this.$refs.list.search()
+      }
     },
     returnList() {
       this.view = 'list'
     },
+    returnData() {
+      this.data = {}
+      this.info = {}
+    },
     toImport({ file }) {
       this.getWorkbook(file)
     },

+ 38 - 7
java代码/ruoyi-ui/src/views/merits/template/parts/list.vue

@@ -2,7 +2,17 @@
   <div id="list">
     <el-row>
       <el-col :span="24">
-        <data-table :fields="fields" :opera="opera" :total="total" :data="list" @query="search">
+        <data-table
+          :fields="fields"
+          :opera="opera"
+          :total="total"
+          :data="list"
+          @query="search"
+          @toEdit="toEdit"
+          @toDelete="toDelete"
+          @toUse="({data})=>toDefaultTemplate(data,true)"
+          @toDisable="({data})=>toDefaultTemplate(data,false)"
+        >
           <template #selfbtn>
             <el-button type="primary" @click="toCreate">添加</el-button>
           </template>
@@ -14,7 +24,7 @@
 
 <script>
 import dataTable from '@/components/free/filter-page-table.vue'
-import { mapState, createNamespacedHelpers } from 'vuex'
+import { createNamespacedHelpers } from 'vuex'
 const { mapActions } = createNamespacedHelpers('template')
 export default {
   name: 'List',
@@ -30,7 +40,9 @@ export default {
       ],
       opera: [
         { label: '编辑', method: 'toEdit' },
-        { label: '删除', method: 'toDelete', type: 'danger' }
+        { label: '使用', method: 'toUse', type: 'success', display: i => !i.is_use, confirm: true },
+        { label: '禁用', method: 'toDisable', type: 'warning', display: i => i.is_use, confirm: true },
+        { label: '删除', method: 'toDelete', type: 'danger', confirm: true }
       ]
     }
   },
@@ -38,7 +50,7 @@ export default {
     this.search()
   },
   methods: {
-    ...mapActions(['query', 'delete']),
+    ...mapActions(['query', 'update', 'delete', 'toUse']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ skip, limit, ...info })
       if (this.$checkRes(res)) {
@@ -46,10 +58,28 @@ export default {
         this.$set(this, `total`, res.total)
       }
     },
-    async toDelete({ data }) {},
-    async toEdit({ data }) {},
+    async toDelete({ data }) {
+      const res = await this.delete(data._id || data.id)
+      if (this.$checkRes(res, res.msg, res.msg || '操作失败')) {
+        this.search()
+      }
+    },
+    async toEdit({ data }) {
+      this.$emit('toEdit', data._id)
+    },
     async toCreate() {
       this.$emit('toAdd')
+    },
+    async toDefaultTemplate(data, boo) {
+      let res
+      if (!boo) {
+        res = await this.update({ id: data._id || data.id, is_use: boo })
+      } else {
+        res = await this.toUse(data._id || data.id)
+      }
+      if (this.$checkRes(res, res.msg, res.msg || '操作失败')) {
+        this.search()
+      }
     }
   }
 }
@@ -58,4 +88,5 @@ export default {
 <style lang="scss" scoped>
 .main {
   padding: 25px 30px 30px;
-}</style>
+}
+</style>