whj 11 meses atrás
pai
commit
1a0c1e73d1

+ 15 - 1
src/api/custom/relation.js

@@ -81,7 +81,21 @@ export function queryCustomRelation (parameter) {
         }
     })
 }
-
+/**
+ * query list func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function getCustomRelation (parameter) {
+  return axios({
+      url: `/custom/relation/${parameter.category}/${parameter.type}`,
+      method: 'get',
+      headers: {
+          'Content-Type': 'application/json;charset=UTF-8'
+      }
+  })
+}
 /**
  * delete batch func
  * parameter: { }

+ 1 - 1
src/views/custom/form/CustomForm.vue

@@ -48,7 +48,7 @@
           <template>
             <a @click="handleView(record)">查看</a>
             <operation-button @click="handleEdit(record)">修改</operation-button>
-            <operation-button v-if="$auth('custom-form-del')" :type="2" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">删除</operation-button>
+            <operation-button :type="2" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">删除</operation-button>
           </template>
         </span>
       </s-table>

+ 6 - 1
src/views/custom/form/modules/BaseForm.vue

@@ -76,6 +76,7 @@ import pick from 'lodash.pick'
 import { addCustomForm, updateCustomForm } from '@/api/custom/form'
 import { queryWorkflow } from '@/api/workflow/workflow'
 import FormComponent from './component/index.vue'
+import values from 'core-js/fn/object/values'
 export default {
   name: 'BaseCustomForm',
   components: {
@@ -102,6 +103,7 @@ export default {
         config: {
           layout: 2,
         },
+        num: 1,
       },
       workFlowList: [],
     }
@@ -144,6 +146,7 @@ export default {
       } = this
       // 日期处理
       this.formValue = record
+      this.type = record.category
       this.queryFields = this.formValue.queryFields.map((item) => item.fieldName)
       this.formComponentConfig = JSON.parse(record.jsonString)
       this.$nextTick(() => {
@@ -168,12 +171,13 @@ export default {
               ...values,
             }
           })
-          this.$refs.formComponent.base(this.formComponentConfig)
+          this.$refs.formComponent.base(this.formComponentConfig, this.formValue)
           break
         case 1:
           this.formComponentConfig = {
             components: this.$refs.formComponent.components,
             config: this.$refs.formComponent.config,
+            num: this.$refs.formComponent.num,
           }
           this.current++
           break
@@ -227,6 +231,7 @@ export default {
         config: {
           layout: 2,
         },
+        num: 1,
       }
       this.form.resetFields()
       if (this.BaseTool.Object.isNotBlank(values)) {

+ 24 - 3
src/views/custom/form/modules/component/index.vue

@@ -51,6 +51,7 @@ import { VueDraggable } from 'vue-draggable-plus'
 import Detail from './modules/Detail.vue'
 import MComponent from './modules/Component.vue'
 import SelectInfo from './modules/SelectInfo'
+import { getCustomRelation } from '@/api/custom/relation'
 
 import { componentBaseList, componenHidetList } from './modules/components'
 export default {
@@ -91,19 +92,39 @@ export default {
   },
   created() {},
   mounted() {
-    this.handleSelect({}, this.config)
+    // this.handleSelect({}, this.config)
   },
   methods: {
-    base(record) {
+    base(record, params = {}) {
       this.components = record.components
       this.config = record.config
+      this.num = record.num
+      if (this.components.length == 0) {
+        getCustomRelation(params).then((res) => {
+          const datas = JSON.parse(res.data.json)
+          const components = datas.forEach((item) => {
+            const newVal = [...componentBaseList, ...componenHidetList].find(
+              (component) => item.type === component.type
+            )
+            const component = {
+              ...newVal,
+              value: item.englishName,
+              id: String(+new Date()),
+              label: item.chineseName,
+              isDelete: false,
+            }
+            console.log(component)
+            this.components.push(component)
+          })
+        })
+      }
     },
     onClone(element) {
       // 生成随机id
       const val = {
         ...JSON.parse(JSON.stringify(element)),
         value: `${element.value}${this.num}`,
-        id: Math.floor(Math.random() * 10000000000000),
+        id: String(+new Date()),
       }
       this.handleSelect(val)
       return val

+ 7 - 2
src/views/custom/form/modules/component/modules/Detail.vue

@@ -107,8 +107,8 @@
           <a-button type="primary" @click="addForm()">添加到表单</a-button>
         </a-form-item> -->
       </template>
-      <a-popconfirm title="确定删除该组件?" ok-text="确定" cancel-text="取消" @confirm="deleteModel">
-        <a-button type="danger" style="width:100%">删除</a-button>
+      <a-popconfirm title="确定删除该组件?" :disabled="!model.isDelete" ok-text="确定" cancel-text="取消" @confirm="deleteModel">
+        <a-button type="danger" :disabled="!model.isDelete" style="width:100%">删除</a-button>
       </a-popconfirm>
     </a-form>
     <a-form size="small" v-if="selectKey === '1'">
@@ -186,6 +186,11 @@ export default {
     },
     deleteModel() {
       this.$emit('delete', this.model)
+      this.model = {
+        attrs: {
+          placeholder: '',
+        },
+      }
     },
     dictChange(tableName) {
       getTableInfos({ tableName }).then((res) => {

+ 9 - 0
src/views/custom/form/modules/component/modules/components.js

@@ -6,6 +6,7 @@ export const componentBaseList = [
     value: 'input',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '单行文本',
     attrs: {
       placeholder: '请输入'
@@ -18,6 +19,7 @@ export const componentBaseList = [
     value: 'textarea',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '多行文本',
     attrs: {
       placeholder: '请输入'
@@ -30,6 +32,7 @@ export const componentBaseList = [
     value: 'number',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '数字',
     attrs: {
       placeholder: '请输入',
@@ -45,6 +48,7 @@ export const componentBaseList = [
     value: 'select',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '下拉框',
     attrs: {
       options: [
@@ -71,6 +75,7 @@ export const componentBaseList = [
     value: 'date',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '日期时间',
     attrs: {
       placeholder: '请输入',
@@ -85,6 +90,7 @@ export const componentBaseList = [
     value: 'divider',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '分割线',
     attrs: {
       orientation: 'center'
@@ -100,6 +106,7 @@ export const componenHidetList = [
     value: 'uploadFile',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '文件上传',
     attrs: {
       placeholder: '请输入',
@@ -113,6 +120,7 @@ export const componenHidetList = [
     value: 'uploadImg',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '图片上传',
     attrs: {
       placeholder: '请输入',
@@ -126,6 +134,7 @@ export const componenHidetList = [
     value: 'id',
     dependentId: false,
     required: true,
+    isDelete:true,
     label: '选择数据',
     attrs: {
       placeholder: '请选择',

+ 3 - 3
src/views/custom/relation/modules/BaseForm.vue

@@ -56,7 +56,7 @@
         </template>
         <template #type="text,record">
           <a-select v-model="record.type">
-            <a-select-option v-for="{name,type} in componentBaseList" :value="type" :key="type">
+            <a-select-option v-for="{name,type} in componentList" :value="type" :key="type">
               {{ name }}
             </a-select-option>
           </a-select>
@@ -76,7 +76,7 @@
 
 <script>
 import pick from 'lodash.pick'
-import { componentBaseList } from '@/views/custom/form/modules/component/modules/components'
+import { componentBaseList, componenHidetList } from '@/views/custom/form/modules/component/modules/components'
 import MComponent from '@/views/custom/form/modules/component/modules/Component.vue'
 import { addCustomRelation, updateCustomRelation } from '@/api/custom/relation'
 export default {
@@ -91,7 +91,7 @@ export default {
       form: this.$form.createForm(this),
       visible: false,
       // 下拉框map
-      componentBaseList: componentBaseList,
+      componentList: [...componentBaseList, ...componenHidetList],
       categoryMap: {},
       type: 0,
       childrenMaps: [],