hfxc226 3 жил өмнө
parent
commit
c013bbfe4a

+ 2 - 2
src/views/customize/fieldTemplate/CustomFieldTemplate.vue

@@ -119,10 +119,10 @@ export default {
             return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
           }
         },
-        {
+/*        {
           title: '模板内容',
           dataIndex: 'content'
-        },
+        },*/
         {
           title: '类型',
           dataIndex: 'type',

+ 25 - 9
src/views/customize/fieldTemplate/modules/BaseForm.vue

@@ -72,13 +72,13 @@
       :data-source="data"
       :columns="columns"
       tableLayout="auto"
-      rowKey="id"
+      rowKey="fieldName"
       :row-selection="rowSelection">
       <span slot="action" slot-scope="record">
         <template>
           <a @click="handleParam(record)">修改</a>
           <a-divider type="vertical" />
-          <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelParam(record.id)">
+          <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelParam(record.fieldName)">
             <a>删除</a>
           </a-popconfirm>
         </template>
@@ -243,6 +243,7 @@ export default {
       this.visible = false
       this.confirmLoading = false
       this.form.resetFields()
+      this.data = []
       if (this.BaseTool.Object.isNotBlank(values)) {
         this.$emit('ok', values)
       } else {
@@ -254,15 +255,30 @@ export default {
       modal.base(record)
     },
     handleParamList (values) {
-      console.log(values)
-      if (this.data == null) {
-        this.data = []
+      let dataSource = [...this.data]
+      if (dataSource == null) {
+        dataSource = []
+      }
+      if (values.label == null || values.label === '') {
+        return
+      }
+      let find = false
+      for (let j = 0; j < dataSource.length; j++) {
+        if (values.fieldName === dataSource[j].fieldName) {
+          find = true
+          this.data = dataSource.map(item => {
+            return item.fieldName === values.fieldName ? values : item
+          })
+          break
+        }
+      }
+      if (!find) {
+        dataSource.push(values)
       }
-      this.data.push(values)
     },
-    handleDelParam (index) {
-      console.log(index)
-      this.data.splice(index, 1)
+    handleDelParam (fieldName) {
+      const dataSource = [...this.data]
+      this.data = dataSource.filter(item => item.fieldName !== fieldName)
     }
   }
 }

+ 124 - 9
src/views/customize/fieldTemplate/modules/Detail.vue

@@ -1,7 +1,14 @@
 <template>
   <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
+    <a-row :gutter="48" slot="extra">
+      <a-col :md="48" :sm="48">
+        <span class="table-page-search-submitButtons" style="float: right">
+          <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
+        </span>
+      </a-col>
+    </a-row>
     <detail-list title="" :col="2">
-      <detail-list-item term="模板内容">{{ model.content }}</detail-list-item>
+      <!--      <detail-list-item term="模板内容">{{ model.content }}</detail-list-item>-->
       <detail-list-item term="类型">{{ BaseTool.Object.getField(this.typeMap,model.type) }}</detail-list-item>
       <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
       <detail-list-item term="更新日期">{{ model.updateTime }}</detail-list-item>
@@ -19,21 +26,33 @@
       rowKey="fieldName">
       <span slot="action" slot-scope="record">
         <template>
-          <a @click="handleParam(record)">修改</a>
-          <a-divider type="vertical" />
-          <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelParam(record.id)">
-            <a>删除</a>
-          </a-popconfirm>
+          <a @click="handleOptionList(record)">下拉选项</a>
         </template>
       </span>
     </a-table>
+    <a-modal
+      title="下拉选项"
+      :width="800"
+      :visible="visibleOptions"
+      class="ant-modal2"
+      @cancel="handleCancel2">
+      <a-table
+        bordered
+        :data-source="dataOptions"
+        :columns="columnOptions"
+        tableLayout="auto"
+        rowKey="name">
+      </a-table>
+      <template slot="footer">
+        <a-button :loading="confirmLoading" type="default" @click="handleCancel2()">关闭</a-button>
+      </template>
+    </a-modal>
   </a-card>
 </template>
 
 <script>
 import DetailList from '@/components/tools/DetailList'
 const DetailListItem = DetailList.Item
-
 export default {
   name: 'CustomFieldTemplateDetail',
   components: {
@@ -46,8 +65,11 @@ export default {
       mdl: {},
       modalTitle: null,
       visible: false,
+      visibleOptions: false,
       // 下拉框map
       typeMap: {},
+      typeFieldMap: {},
+      yesNoMap: {},
       model: {
         'content': null,
         'type': null,
@@ -57,23 +79,116 @@ export default {
         'updateUserId': null,
         'updateUserName': null,
         'secondTypeId': null
-      }
+      },
+      data: [],
+      dataOptions: [],
+      // 表头
+      columns: [
+        {
+          title: '序号',
+          dataIndex: 'index',
+          customRender: (text, record, index) => {
+            return index + 1
+          }
+        },
+        {
+          title: '显示名称',
+          dataIndex: 'label'
+        },
+        {
+          title: '字段名称',
+          dataIndex: 'fieldName'
+        },
+        {
+          title: '类型',
+          dataIndex: 'type',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Object.getField(this.typeFieldMap, text)
+          }
+        },
+        {
+          title: '是否必填',
+          dataIndex: 'required',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Object.getField(this.yesNoMap, text)
+          }
+        },
+        {
+          title: '显示行数',
+          dataIndex: 'rows',
+          width: 120
+        },
+        {
+          title: '排序',
+          dataIndex: 'sort',
+          width: 150
+        },
+        {
+          title: '默认值',
+          dataIndex: 'defaultValue',
+          width: 150
+        },
+        {
+          title: '最小长度',
+          dataIndex: 'minLength',
+          width: 150
+        },
+        {
+          title: '最大长度',
+          dataIndex: 'maxLength',
+          width: 150
+        },
+        {
+          title: '操作',
+          key: 'action',
+          align: 'center',
+          scopedSlots: { customRender: 'action' }
+        }
+      ],
+      columnOptions: [
+        {
+          title: '序号',
+          dataIndex: 'index',
+          customRender: (text, record, index) => {
+            return index + 1
+          }
+        },
+        {
+          title: '参数名称',
+          dataIndex: 'name'
+        },
+        {
+          title: '参数值',
+          dataIndex: 'value'
+        }
+      ]
     }
   },
   created () {
     // 下拉框map
-
     this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CUSTOM_FIELD_TEMPLATE_TYPE)
+    this.typeFieldMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CUSTOM_FIELD_TEMPLATE_FILED_TYPE)
+    this.yesNoMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
   },
   methods: {
     base (record) {
       this.visible = true
       this.modalTitle = '详情'
       this.model = record
+      this.data = JSON.parse(record.content)
     },
     handleCancel () {
       this.visible = false
       this.confirmLoading = false
+      this.$emit('ok')
+    },
+    handleCancel2 () {
+      this.visibleOptions = false
+      this.dataOptions = []
+    },
+    handleOptionList (record) {
+      this.visibleOptions = true
+      this.dataOptions = record.optionList
     }
   }
 }

+ 8 - 22
src/views/customize/fieldTemplate/modules/OptionForm.vue

@@ -41,6 +41,7 @@
 <script>
 import { queryUserDept } from '@/api/upms/user-dept'
 import { queryUser } from '@/api/upms/user'
+import pick from 'lodash.pick'
 
 export default {
   name: 'DispatchBaseForm',
@@ -51,23 +52,13 @@ export default {
       form: this.$form.createForm(this),
       visible: false,
       // 下拉框map
-      sourceMap: {},
-      levelMap: {},
-      statusMap: {},
       record: {},
-      userList: [],
-      deptUserList: []
     }
   },
   props: {
   },
   created () {
     // 下拉框map
-    this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
-    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
-    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
-    this.getUsers()
-    this.getDeptUsers()
   },
   methods: {
     base (record) {
@@ -75,17 +66,13 @@ export default {
       // 如果是空标识添加
       this.modalTitle = '派工'
       this.record = record
-    },
-    getDeptUsers () {
-      queryUserDept({ deptCode: this.DictCache.VALUE.SYS_DEPT_CODE.XIAN_CHANG_WEI_XIU_ZU, userStatus: 1 }).then(res => {
-        queryUserDept({ deptCode: this.DictCache.VALUE.SYS_DEPT_CODE.CHANG_NEI_WEI_XIU_ZU, userStatus: 1 }).then(res2 => {
-          this.deptUserList = res.data.concat(res2.data)
-        })
-      })
-    },
-    getUsers () {
-      queryUser({ status: 1 }).then(res => {
-        this.userList = res.data
+      const { form: { setFieldsValue } } = this
+      // 日期处理
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign(pick(record, [
+          'name',
+          'value'
+        ])))
       })
     },
     save () {
@@ -103,7 +90,6 @@ export default {
       this.visible = false
       this.confirmLoading = false
       this.form.resetFields()
-      console.log(values)
       if (this.BaseTool.Object.isNotBlank(values)) {
         console.log(values)
         this.$emit('ok', values)

+ 52 - 15
src/views/customize/fieldTemplate/modules/ParamForm.vue

@@ -71,7 +71,7 @@
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
             <a-input
-              v-decorator="['rows']"/>
+              v-decorator="['rows', {rules: [{required: true, message: '不能为空'}]}]"/>
           </a-form-item>
         </row-item>
         <row-item>
@@ -81,7 +81,7 @@
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
             <a-input
-              v-decorator="['sort']"/>
+              v-decorator="['sort', {rules: [{required: true, message: '不能为空'}]}]"/>
           </a-form-item>
         </row-item>
         <row-item>
@@ -91,7 +91,7 @@
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
             <a-input
-              v-decorator="['minLength']"/>
+              v-decorator="['minLength', {rules: [{required: true, message: '不能为空'}]}]"/>
           </a-form-item>
         </row-item>
         <row-item>
@@ -101,7 +101,7 @@
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
             <a-input
-              v-decorator="['maxLength']"/>
+              v-decorator="['maxLength', {rules: [{required: true, message: '不能为空'}]}]"/>
           </a-form-item>
         </row-item>
         <row-item>
@@ -132,13 +132,13 @@
       :data-source="data"
       :columns="columns"
       tableLayout="auto"
-      rowKey="id"
+      rowKey="name"
       :row-selection="rowSelection">
       <span slot="action" slot-scope="record">
         <template>
           <a @click="handleOption(record)">修改</a>
           <a-divider type="vertical" />
-          <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelOption(record.id)">
+          <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelOption(record.name)">
             <a>删除</a>
           </a-popconfirm>
         </template>
@@ -154,6 +154,8 @@
 <script>
 import OptionForm from './OptionForm'
 import DetailList from '@/components/tools/DetailList'
+import pick from 'lodash.pick'
+import Vue from 'vue'
 export default {
   name: 'FieldTemplateOptionForm',
   components: {
@@ -223,7 +225,22 @@ export default {
       // 如果是空标识添加
       this.modalTitle = '字段设置'
       this.record = record
-      this.data = record.optionList
+      this.data = record.optionList || []
+      const { form: { setFieldsValue } } = this
+      // 日期处理
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign(pick(record, [
+          'label',
+          'fieldName',
+          'type',
+          'required',
+          'sort',
+          'rows',
+          'minLength',
+          'maxLength',
+          'defaultValue'
+        ])))
+      })
     },
     save () {
       const { form: { validateFieldsAndScroll } } = this
@@ -233,13 +250,14 @@ export default {
           this.confirmLoading = false
           return
         }
-        values.optionList = this.optionList
+        values.optionList = this.data
         this.handleCancel(values)
       })
     },
     handleCancel (values) {
       this.visible = false
       this.confirmLoading = false
+      this.data = []
       this.form.resetFields()
       console.log(values)
       if (this.BaseTool.Object.isNotBlank(values)) {
@@ -257,15 +275,34 @@ export default {
       }
     },
     handleOptionList (values) {
-      console.log(values)
-      if (this.optionList == null) {
-        this.optionList = []
+      let dataSource = [...this.data]
+      if (dataSource == null) {
+        dataSource = []
+      }
+      if (values.name == null || values.name === '') {
+        return
+      }
+      let find = false
+      console.log('data.length: ' + dataSource.length)
+      for (let j = 0; j < dataSource.length; j++) {
+        if (values.name === dataSource[j].name) {
+          find = true
+          this.data = dataSource.map(item => {
+            return item.name === values.name ? values : item
+          })
+          break
+        }
+      }
+      if (!find) {
+        dataSource.push(values)
+        console.log('data.length: ' + dataSource.length)
+        this.data = dataSource
+        console.log('data.length: ' + this.data.length)
       }
-      this.optionList.push(values)
     },
-    handleDelOption (index) {
-      console.log(index)
-      this.optionList.splice(index, 1)
+    handleDelOption (name) {
+      const dataSource = [...this.data]
+      this.data = dataSource.filter(item => item.name !== name)
     }
   }
 }

+ 1 - 1
src/views/store/outstoreform/modules/BaseForm.vue

@@ -438,7 +438,7 @@ export default {
     handleSpareStoreSelected (record, keys, rows) {
       const { data } = this
       for (let i = 0; i < rows.length; i++) {
-        var find = false
+        let find = false
         for (let j = 0; j < data.length; j++) {
           if (rows[i].id === data[j].id || rows[i].spareId === data[j].spareId) {
             find = true