Explorar o código

附件组件增加获取被点击次数函数

cyy hai 2 días
pai
achega
a897c3e2b6

+ 1 - 0
src/business/platform/file/attachment/selector.vue

@@ -429,6 +429,7 @@ export default {
         // 事件处理
         handleActionEvent (action, index, data, type) {
             this.index = index
+            this.$emit('click', action, index)
             switch (action) {
                 case 'select': // 选择
                     this.selectorVisible = true

+ 7 - 0
src/business/platform/form/formrender/dynamic-form/dynamic-form-field.vue

@@ -371,6 +371,7 @@
             :media-type="fieldOptions.media_type"
             :media="fieldOptions.media"
             :style="{ width: width }"
+            @click="handleAttachmentClick"
             v-on="$listeners"
         />
         <!-- 选择器-->
@@ -1134,6 +1135,12 @@
             changeFormData(name, value) {
                 this.$emit('change-data', name, value)
             },
+            // 附件点击计数
+            handleAttachmentClick() {
+                if (this.dynamicForm && this.dynamicForm.incrementFieldClickNum) {
+                    this.dynamicForm.incrementFieldClickNum(this.field.name, this.code, this.row)
+                }
+            },
             // 请求记忆数据库
             reqPhrase(orderId, field) {
                 if (!this.watchKey || this.inputKey != field.name + field.field_text) {

+ 12 - 0
src/business/platform/form/formrender/dynamic-form/dynamic-form-table.vue

@@ -266,6 +266,9 @@ export default {
         },
         elFormItem: {
             default: ''
+        },
+        dynamicForm: {
+            default: null
         }
     },
     data () {
@@ -1209,6 +1212,15 @@ export default {
          */
         setData (name, value) {
             this.updateFormData(name, value)
+        },
+        /**
+         * 获取附件字段点击次数
+         */
+        getClickNum (row, fieldName) {
+            if (this.dynamicForm && this.dynamicForm.getClickNum) {
+                return this.dynamicForm.getClickNum(fieldName, row, this.code)
+            }
+            return 0
         }
     }
 }

+ 30 - 1
src/business/platform/form/formrender/dynamic-form/dynamic-form.vue

@@ -172,7 +172,8 @@
                 invalidFields: {},
                 activeStep: 0,
                 titleList: [],
-                StaOrRec: []
+                StaOrRec: [],
+                fieldClickNum: {} // 附件字段点击次数
             }
         },
         computed: {
@@ -616,6 +617,34 @@
             // 将对象参数传入, 进行渲染
             getStatisOrRecord(type) {
                 this.StaOrRec = type
+            },
+            /**
+             * 获取附件点击次数的 key
+             */
+            getClickNumKey(fieldName, code, row) {
+                if (this.$utils.isNotEmpty(row) || row === 0) {
+                    return `${code}.${row}.${fieldName}`
+                }
+                return fieldName
+            },
+            /**
+             * 递增附件字段点击次数
+             */
+            incrementFieldClickNum(fieldName, code, row) {
+                const key = this.getClickNumKey(fieldName, code, row)
+                const clickNum = (this.fieldClickNum[key] || 0) + 1
+                this.$set(this.fieldClickNum, key, clickNum)
+                return clickNum
+            },
+            /**
+             * 获取附件字段点击次数
+             * @param {String} fieldName 字段名
+             * @param {Number} row 子表行号(主表字段可不传)
+             * @param {String} code 子表表名(主表字段可不传)
+             */
+            getClickNum(fieldName, row, code) {
+                const key = this.getClickNumKey(fieldName, code, row)
+                return this.fieldClickNum[key] || 0
             }
             /**
              * 获取表单字段的具体控件组件实例

+ 9 - 0
src/business/platform/form/formrender/index.vue

@@ -484,6 +484,15 @@
             getRefsField(fieldName) {
                 return this.getForm().getRefsField(fieldName)
             },
+            /**
+             * 获取附件字段点击次数
+             * @param {String} fieldName 字段名
+             * @param {Number} row 子表行号(主表字段可不传)
+             * @param {String} code 子表表名(主表字段可不传)
+             */
+            getClickNum(fieldName, row, code) {
+                return this.getForm().getClickNum(fieldName, row, code)
+            },
             /* 给与表头赋值关联对话框及数据*/
             getTableList(list) {
                 return this.getForm().getTableList(list)