Browse Source

Merge branch 'master' of http://62.234.61.92:3000/wjm/mec-cloud_IntelligentManufacturing_CRM

zyz 1 year ago
parent
commit
ba9e129154

+ 9 - 1
zkqy-ui/src/components/updateModule/k-form-design/packages/components/KFormBuild/index.vue

@@ -76,8 +76,17 @@ export default {
     defaultValue: {
       type: Object,
       default: () => ({})
+    },
+    tableData: {
+      type: Array,
+      default: () => []
     }
   },
+  provide() {
+    return {
+      tableData: () => this.tableData,
+    };
+  },
   components: {
     buildBlocks
   },
@@ -101,7 +110,6 @@ export default {
       this.form.resetFields();
     },
     getData() {
-      console.log('this.form',this.form);
       // 提交函数,提供父级组件调用
       return new Promise((resolve, reject) => {
         try {

+ 7 - 2
zkqy-ui/src/components/updateModule/k-form-design/packages/components/KFormDesign/index.vue

@@ -165,7 +165,7 @@ export default {
   props: {
     title: {
       type: String,
-      default: "表单设计器 --by kcz"
+      default: "表单设计器"
     },
     showHead: {
       type: Boolean,
@@ -529,7 +529,7 @@ export default {
     }
   },
   created() {
-    let blackList=['评分','警告提示','HTML','富文本','按钮']
+    let blackList=['评分','警告提示','HTML','富文本','按钮','级联选择器']
     this.loadState = true;
     nodeSchema.addComputed(this.schemaGroup);
     this.schemaGroup = tempData;
@@ -537,6 +537,11 @@ export default {
     this.schemaGroup[0].list = this.schemaGroup[0].list.filter(item => {
       return !blackList.some(v=>v==item.label)
     })
+    this.schemaGroup[0].list.forEach(item => {
+      if (item.label == '树形选择器') {
+        item.label='级联选择器'
+      }
+    })
   }
 };
 </script>

+ 1 - 1
zkqy-ui/src/components/updateModule/k-form-design/packages/components/KFormDesign/module/formItemProperties.vue

@@ -847,7 +847,7 @@ export default {
       if (flag) {
       item.model='batch.'+item.tableName
       } else if(item.type){
-        item.model=item.tableName
+        item.model='tableShow.'+item.tableName
       }else {
       item.model=''
     }

+ 1 - 0
zkqy-ui/src/components/updateModule/k-form-design/packages/components/KFormDesign/module/layoutItem.vue

@@ -22,6 +22,7 @@
         @click.stop="handleSelectItem(record)"
       >
         <a-form-item
+          :colon="false"
           :label="!record.options.showLabel ? '' : record.label"
           :label-col="
             config.layout === 'horizontal' && record.options.showLabel

+ 10 - 11
zkqy-ui/src/components/updateModule/k-form-design/packages/components/KTableShow/index.vue

@@ -37,14 +37,10 @@ export default {
   watch: {
     
   },
+  inject:['tableData'],
   data() {
     return {
-      tempData:[
-        {
-          id:'1',
-          user_name:'张三',
-        }
-      ],
+      tempData:[],
     };
   },
   computed: {
@@ -56,13 +52,16 @@ export default {
       this.$emit('change',selection.map(item=>item.id))
     },
     
+    
   },
   created() {
-    console.log('record',this.record);
-    console.log('value',this.value);
-    console.log('dynamicData',this.dynamicData);
-    console.log('parentDisabled',this.parentDisabled);
-    console.log('config',this.config);
+    // console.log('record',this.record);
+    // console.log('value',this.value);
+    // console.log('dynamicData',this.dynamicData);
+    // console.log('parentDisabled',this.parentDisabled);
+    // console.log('config', this.config);
+    // console.log(this.tableData());
+    this.tempData = this.tableData();
   }
 };
 </script>

+ 16 - 4
zkqy-ui/src/components/updateModule/k-form-design/packages/components/KTextShow/KTextShow.vue

@@ -3,18 +3,23 @@
     :style="{
       textAlign: record.options.textAlign,
       transform: 'translateY(-2px)',
-      paddingRight: '8px'
+  paddingRight: '8px',
+    
     }"
   >
     <label
-      :class="{ 'ant-form-item-required': record.options.showRequiredMark }"
+    id="text-show-label"
+      :class="{
+  'ant-form-item-required': record.options.showRequiredMark,
+    }"
       :style="{
         fontFamily: record.options.fontFamily,
         fontSize: record.options.fontSize,
-        color: record.options.color
+        color: record.options.color,
+        
       }"
       v-text="record.value"
-    ></label>{{ value }}
+    ></label>{{ value}}
   </div>
 </template>
 <script>
@@ -33,3 +38,10 @@ export default {
   }
 };
 </script>
+<style lang="scss">
+.ant-form-item-label > label::after{
+  content: '' !important;
+  margin-right: 5px;
+}
+
+</style>

+ 25 - 0
zkqy-ui/src/router/index.js

@@ -94,6 +94,31 @@ export const constantRoutes = [
       }
     ]
   },
+  {
+    path: '/dragPositionIndex',
+    component: Layout,
+    hidden: true,
+    name: 'dragPositionIndex',
+    meta: {
+      title: "布局编辑",
+      icon: "form",
+      noCache: false,
+      link: null
+    },
+    children: [
+      {
+        name: 'dragPositionIndex',
+        path: 'index',
+        component: () => import('@/views/system/formGroupMange/dragPositionIndex'),
+        meta: {
+          title: "布局编辑",
+          icon: "form",
+          noCache: false,
+          link: null
+        },
+      }
+    ]
+  },
   {
     path: '/progressShow',
     component: Layout,

+ 50 - 1
zkqy-ui/src/views/system/formGroupMange/component/DragPosition.vue

@@ -62,6 +62,7 @@ import TopToolBar from "./TopToolBar.vue"; //右侧tab
 import { updateFormGroup } from "@/api/system/formGroup";
 import JSONViewer from "./JSONViewer.vue";
 import PreView from "./PreView.vue";
+import Result from "@/components/Crontab/result.vue";
 
 export default {
   name: "DragPosition",
@@ -177,10 +178,25 @@ export default {
     },
   },
   methods: {
+    // 添加表单json数据
+    addFormJSONData(data) {
+      df = (arr) => {
+        arr.forEach((element) => {
+          if (element.type == "form") {
+            // element.dfVueTemplate=
+          }
+        });
+      };
+    },
     // 预览展示
     showPreView() {
+      console.log(this.layoutData, formList);
+      let tempLayoutData = JSON.parse(JSON.stringify(this.layoutData));
+
       this.$refs.PreViewRef.setLayoutData(this.layoutData, formList);
-      this.$refs.PreViewRef.showPreView();
+      this.$nextTick(() => {
+        this.$refs.PreViewRef.showPreView();
+      });
     },
     // JSON展示回调
     showJSONData() {
@@ -224,6 +240,7 @@ export default {
       } else {
         this.layoutData.list.push(...res);
       }
+      console.log(this.layoutData);
       // this.schemaGroup[0].list = res;
     },
     // 预览json
@@ -233,9 +250,41 @@ export default {
     handleStart(type) {
       this.startType = type;
     },
+    checkIsRepeat(dfNickname) {
+      console.log(dfNickname, this.layoutData);
+      let res = {
+        result: false,
+      };
+      let checkDF = (list, res) => {
+        for (let i = 0; i < list.length; i++) {
+          let temp = list[i];
+          if (temp.type == "form") {
+            console.log(temp.dfNickname, dfNickname);
+            if (temp.dfNickname == dfNickname) {
+              res.result = true;
+            }
+          } else if (temp.type == "tabs" || temp.type == "grid") {
+            for (let k = 0; k < temp.columns.length; k++) {
+              checkDF(temp.columns[k].list, res);
+            }
+          }
+        }
+      };
+      checkDF(this.layoutData.list, res);
+      return res.result;
+    },
+    // 校验当前表单是否已存在
     handleListPush(item) {
       console.log(this.selectItem);
       console.log(item);
+      if (item.type == "form") {
+        let isRepeat = this.checkIsRepeat(item.dfNickname);
+        console.log("isRepeat", isRepeat);
+        if (isRepeat) {
+          this.$message.error("该表单已存在!");
+          return;
+        }
+      }
       // 生成key值
       // if (!this.selectItem?.key) {
       // 在没有选择表单时,将数据push到this.data.list

+ 1 - 0
zkqy-ui/src/views/system/formGroupMange/component/LayoutItem.vue

@@ -98,6 +98,7 @@
           class="delete"
           :class="record.key === selectItem.key ? 'active' : 'unactivated'"
           @click.stop="deleHandle(record)"
+          style="right: 50%; transform: translateX(100%)"
         >
           <i class="el-icon-delete"></i>
         </div>

+ 1 - 0
zkqy-ui/src/views/system/formGroupMange/component/PreView.vue

@@ -10,6 +10,7 @@
       :key="index"
       class="drag-move"
       :record="item"
+      :formData="formData"
     />
     <template #footer>
       <span>

+ 1 - 1
zkqy-ui/src/views/system/formGroupMange/component/TopToolBar.vue

@@ -38,7 +38,7 @@
         type="text"
         size="medium"
         @click="$emit('showPreView')"
-        icon="el-icon-document"
+        icon="el-icon-picture-outline"
         round
       ></el-button>
     </el-tooltip>

+ 424 - 0
zkqy-ui/src/views/system/formGroupMange/dragPositionIndex.vue

@@ -0,0 +1,424 @@
+<template>
+  <div class="main-wrap">
+    <div class="drag-position">
+      <!-- 左侧面板区域 start-->
+      <!-- <LetfPanel
+        :formList="formList"
+        @handleClick="panelClickHandler"
+        @start="generateKey"
+      ></LetfPanel> -->
+      <a-collapse style="width: 370px">
+        <a-collapse-panel
+          v-for="(item, index) in schemaGroup"
+          :header="item.title"
+          :key="index"
+        >
+          <collapseItem
+            :list="item.list"
+            @generateKey="generateKey"
+            @handleListPush="handleListPush"
+            @start="handleStart"
+          />
+        </a-collapse-panel>
+      </a-collapse>
+      <!-- 左侧面板区域 end-->
+      <!-- 中间拖拽区域 start-->
+      <div class="drag-wrap">
+        <!-- 顶部工具 -->
+        <TopToolBar
+          @showJSON="showJSON"
+          @saveJSON="saveJSON"
+          @showJSONData="showJSONData"
+          @showPreView="showPreView"
+        ></TopToolBar>
+        <CenterArea
+          :data="layoutData"
+          :selectItem="selectItem"
+          @setCurrentTarget="setCurrentTarget"
+          :noModel="noModel"
+          ref="centerAreaRef"
+        ></CenterArea>
+      </div>
+      <!-- 中间拖拽区域 end-->
+      <!-- 右侧面板区域 start -->
+      <RightPanel class="right-panel" :selectItem="selectItem"></RightPanel>
+      <!-- 右侧面板区域 end -->
+      <!-- JSON数据预览 -->
+      <JSONViewer ref="JSONViewerRef"></JSONViewer>
+      <!-- 布局效果预览 -->
+      <PreView ref="PreViewRef"></PreView>
+    </div>
+  </div>
+</template>
+
+<script>
+import { formList } from "./component/tempJson.js";
+
+import LetfPanel from "./component/LetfPanel.vue";
+import CenterArea from "./component/CenterArea.vue";
+import collapseItem from "./component/collapseItem.vue"; //左侧tab
+import RightPanel from "./component/RightPanel.vue"; //右侧tab
+import TopToolBar from "./component/TopToolBar.vue"; //右侧tab
+import { updateFormGroup, getFormGroup } from "@/api/system/formGroup";
+import JSONViewer from "./component/JSONViewer.vue";
+import PreView from "./component/PreView.vue";
+
+export default {
+  name: "dragPositionIndex",
+  props: [],
+  components: {
+    LetfPanel,
+    CenterArea,
+    collapseItem,
+    RightPanel,
+    TopToolBar,
+    JSONViewer,
+    PreView,
+  },
+  data() {
+    return {
+      formGroupData: {},
+      startType: "",
+      layoutData: {
+        list: [],
+      },
+      mainList: [], //拖拽区域数据
+      selectItem: {}, //当前拖拽对象
+      noModel: [
+        "button",
+        "divider",
+        "card",
+        "grid",
+        "tabs",
+        "table",
+        "alert",
+        "text",
+        "html",
+      ],
+      schemaGroup: [
+        {
+          title: "表单控件",
+          list: [],
+        },
+        {
+          title: "布局组件",
+          list: [
+            {
+              label: "标签页布局",
+              type: "tabs",
+              options: {
+                tabBarGutter: null,
+                type: "line",
+                tabPosition: "top",
+                size: "default",
+                noFormItem: true,
+                animated: true,
+              },
+              columns: [
+                {
+                  value: "1",
+                  label: "选项1",
+                  list: [],
+                  tableName: "",
+                },
+                {
+                  value: "2",
+                  label: "选项2",
+                  list: [],
+                  tableName: "",
+                },
+              ],
+              key: "",
+              model: "",
+            },
+            {
+              type: "grid",
+              label: "栅格布局",
+              icon: "icon-zhage",
+              columns: [
+                {
+                  span: 12,
+                  list: [],
+                },
+                {
+                  span: 12,
+                  list: [],
+                },
+              ],
+              options: {
+                noFormItem: true,
+                gutter: 0,
+              },
+              key: "",
+              model: "",
+            },
+            {
+              type: "divider",
+              label: "分割线",
+              icon: "icon-fengexian",
+              options: {
+                orientation: "left",
+                noFormItem: true,
+                title: "提示信息",
+              },
+              key: "",
+              model: "",
+            },
+          ],
+        },
+      ],
+    };
+  },
+  created() {
+    // this.schemaGroup[0].list = formList;
+  },
+  computed: {
+    formList() {
+      return formList;
+    },
+  },
+  methods: {
+    async initData() {
+      let id = this.$route.query.id;
+      let res = await getFormGroup(id);
+      console.log(res);
+      if (res.code == 200) {
+        let {
+          fGName,
+          formKeys,
+          groupKey,
+          mainTable,
+          id,
+          relationJson,
+          remark,
+          dragFormList,
+          layoutJson,
+        } = res.data;
+        this.formGroupData = {
+          fGName,
+          formKeys,
+          groupKey,
+          mainTable,
+          id,
+          relationJson,
+          remark,
+          dragFormList,
+          layoutJson,
+        };
+        this.initFormData();
+      } else {
+        this.$message.error(res.msg);
+      }
+    },
+    // 添加表单json数据
+    addFormJSONData(data) {
+      df = (arr) => {
+        arr.forEach((element) => {
+          if (element.type == "form") {
+            // element.dfVueTemplate=
+          }
+        });
+      };
+    },
+    // 预览展示
+    showPreView() {
+      console.log(this.layoutData, formList);
+      let tempLayoutData = JSON.parse(JSON.stringify(this.layoutData));
+
+      this.$refs.PreViewRef.setLayoutData(this.layoutData, formList);
+      this.$nextTick(() => {
+        this.$refs.PreViewRef.showPreView();
+      });
+    },
+    // JSON展示回调
+    showJSONData() {
+      this.$refs.JSONViewerRef.setJSONData(JSON.stringify(this.layoutData));
+      this.$refs.JSONViewerRef.showHandler();
+    },
+    // 保存布局数据
+    async saveJSON() {
+      let payLoad = {
+        ...this.formGroupData,
+        layoutJson: JSON.stringify(this.layoutData),
+      };
+      let res = await updateFormGroup(payLoad);
+      if (res.code == 200) {
+        this.$message.success("保存成功!");
+      } else {
+        this.$message.error("网络异常,保存失败!");
+      }
+    },
+    // 初始化表单数据
+    initFormData() {
+      let res = [];
+      this.layoutData.list = [];
+      console.log(this.formGroupData);
+      let { dragFormList, layoutJson } = this.formGroupData;
+      res = dragFormList.map((item, index) => {
+        let { dfName, dfNickname, dfTableName, formKey, dfVueTemplate } = item;
+        return {
+          key: new Date().getTime() + "_" + index,
+          type: "form",
+          label: dfName,
+          dfNickname,
+          dfTableName,
+          formKey,
+          dfVueTemplate,
+        };
+      });
+      this.$set(this.schemaGroup[0], "list", res);
+      if (layoutJson) {
+        this.layoutData = JSON.parse(layoutJson);
+      } else {
+        this.layoutData.list.push(...res);
+      }
+      console.log(this.layoutData);
+      // this.schemaGroup[0].list = res;
+    },
+    // 预览json
+    showJSON() {
+      console.log("json数据", JSON.stringify(this.layoutData));
+    },
+    handleStart(type) {
+      this.startType = type;
+    },
+    checkIsRepeat(dfNickname) {
+      console.log(dfNickname, this.layoutData);
+      let res = {
+        result: false,
+      };
+      let checkDF = (list, res) => {
+        for (let i = 0; i < list.length; i++) {
+          let temp = list[i];
+          if (temp.type == "form") {
+            console.log(temp.dfNickname, dfNickname);
+            if (temp.dfNickname == dfNickname) {
+              res.result = true;
+            }
+          } else if (temp.type == "tabs" || temp.type == "grid") {
+            for (let k = 0; k < temp.columns.length; k++) {
+              checkDF(temp.columns[k].list, res);
+            }
+          }
+        }
+      };
+      checkDF(this.layoutData.list, res);
+      return res.result;
+    },
+    // 校验当前表单是否已存在
+    handleListPush(item) {
+      console.log(this.selectItem);
+      console.log(item);
+      if (item.type == "form") {
+        let isRepeat = this.checkIsRepeat(item.dfNickname);
+        console.log("isRepeat", isRepeat);
+        if (isRepeat) {
+          this.$message.error("该表单已存在!");
+          return;
+        }
+      }
+      // 生成key值
+      // if (!this.selectItem?.key) {
+      // 在没有选择表单时,将数据push到this.data.list
+      const key = item.type + "_" + new Date().getTime();
+      item = {
+        ...item,
+        key,
+        model: key,
+      };
+      if (this.noModel.includes(item.type)) {
+        // 删除不需要的model属性
+        delete item.model;
+      }
+      const itemString = JSON.stringify(item);
+      const record = JSON.parse(itemString);
+      // 删除icon及compoent属性
+      delete record.icon;
+      delete record.component;
+      this.layoutData.list.push(record);
+      this.handleSetSelectItem(record);
+      return false;
+      // }
+      // this.$refs.centerAreaRef.handleCopy(false, item);
+    },
+    handleSetSelectItem(record) {
+      // 操作间隔不能低于100毫秒
+      const newTime = new Date().getTime();
+      if (newTime - this.updateTime < 100) {
+        return false;
+      }
+
+      this.updateTime = newTime;
+
+      // 设置selectItem的值
+      this.selectItem = record;
+      console.log("this.selectItem", this.selectItem);
+
+      // 判断是否选中控件,如果选中则弹出属性面板,否则关闭属性面板
+      // if (record.key) {
+      //   this.startType = record.type;
+      //   this.changeTab(2);
+      // } else {
+      //   this.changeTab(1);
+      // }
+    },
+    panelClickHandler(item) {
+      this.selectItem = item;
+      this.mainList.push(item);
+      this.layoutData.list.push(item);
+      console.log(this.mainList);
+    },
+    setCurrentTarget(item) {
+      console.log("this.selectItem", item);
+      this.selectItem = item;
+      console.log("layoutData", this.layoutData);
+    },
+    generateKey(list, index) {
+      const key = list[index].type + "_" + new Date().getTime();
+      this.$set(list, index, {
+        ...list[index],
+        key,
+        model: key,
+      });
+      if (this.noModel.includes(list[index].type)) {
+        // 删除不需要的model属性
+        delete list[index].model;
+      }
+    },
+  },
+  mounted() {
+    this.initData();
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+ul {
+  margin: 0;
+  padding: 0;
+  list-style: none;
+  display: flex;
+  flex-wrap: wrap;
+}
+.main-wrap {
+  height: calc(100vh - 140px);
+}
+.drag-position {
+  height: calc(100% - 30px);
+  display: flex;
+  .drag-wrap {
+    // box-sizing: border-box;
+    position: relative;
+    // height: 100%;
+    padding: 0 10px;
+    flex: 1;
+  }
+}
+.right-panel {
+  width: 350px;
+  border: 1px solid #dddddd;
+  height: 100%;
+  padding: 5px;
+  border-radius: 5px;
+}
+</style>

+ 7 - 0
zkqy-ui/src/views/system/formGroupMange/index.vue

@@ -706,6 +706,13 @@ export default {
   methods: {
     // 布局回调
     async handlePosition(row) {
+      this.$router.push({
+        path: "/dragPositionIndex/index",
+        query: {
+          id: row.id,
+        },
+      });
+      return;
       let res = await getFormGroup(row.id);
       console.log(res);
       if (res.code == 200) {

+ 6 - 1
zkqy-ui/src/views/system/formGroupMange/preView/preViewItem.vue

@@ -101,7 +101,7 @@ import KFormDesign from "./KFormDesign.vue";
 import draggable from "vuedraggable";
 export default {
   name: "preViewItem",
-  props: ["record"],
+  props: ["record", "formData"],
   components: { FormCard, draggable, KFormDesign },
   data() {
     return {};
@@ -113,6 +113,11 @@ export default {
     },
   },
   methods: {
+    // 获取表单json数据
+    getFormJson(formKey) {
+      return this.formData.filter((item) => item.formKey == formKey)
+        ?.dfVueTemplate;
+    },
     // 删除
     deleHandle(record) {
       console.log("dele", record);