田源
2023-10-16 650e413caddf7d14d6929f8f287d5f443660cb7a
编码申请测试表单回显和码值保存
已修改4个文件
197 ■■■■■ 文件已修改
Source/UBCS-WEB/src/api/code/codeApply.js 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/views/code/Match.vue 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/views/code/codeApply.vue 165 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/api/code/codeApply.js
@@ -13,11 +13,12 @@
//编码申请控件
export const getUsedTemplateByClassifyOid = (params) => {
  return request({
    url: '/api/ubcs-code/codeApplySwingController/getUsedTemplateByClassifyOid',
    url: '/api/ubcs-code/codeApplySwingController/getFormDefineByTemplateOid',
    method: 'get',
    params
  })
}
//码值
export function getCodeRule(params) {
  return request({
    url: 'api/ubcs-code/mdmEngineController/getCodeRuleByClassifyOid',
@@ -25,3 +26,12 @@
    params
  })
}
//保存
export function addSaveCode(data) {
  return request({
    url: 'api/ubcs-code/mdmEngineController/addSaveCode',
    method: 'post',
    data
  })
}
Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue
@@ -62,6 +62,10 @@
      type: String,
      default: "",
    },
    LoadingStatus:{
      type: String,
      default : "code"
    },
    // 列表数据oid
    rowOid: {
      type: String,
@@ -129,7 +133,9 @@
    this.handleResize();
  },
  created() {
    if (this.LoadingStatus === 'code') {
      this.loading = false;
    }
  },
  computed: {
    localTrendsSpan() {
Source/UBCS-WEB/src/views/code/Match.vue
@@ -216,8 +216,16 @@
    searchHandler() {
      this.findvisible = true;
    },
    echoContion(row) {
    echoContion(val) {
      console.log(...val)
      // FindData({
      //   templateOid: this.templateOid,
      //   codeClassifyOid: this.codeClassifyOid,
      //   ...val,
      // }).then((res) => {
      //   this.tableData = res.data.data;
      //   this.page.total = res.data.total
      // });
    },
    deleteHandler() {
      const length = this.selectRow.length;
Source/UBCS-WEB/src/views/code/codeApply.vue
@@ -18,6 +18,7 @@
              key="masterForm" data-key="masterForm"
              v-bind="$attrs"
              :type="type"
              :LoadingStatus="status"
              :TreeValue="TreeValue"
              :eventList="eventList"
              ref="FormTemplate"
@@ -35,8 +36,15 @@
                  @getFormData="getCodeApplyFormData"
                  @referConfigDataUpdate="referConfigDataUpdate"
                ></FormTemplate>
                <el-button
                  @click="submit()"
                  type="primary"
                  size="small"
                  style="float: right"
                >保存</el-button>
              </el-tab-pane>
            </el-tabs>
          </div>
        </basic-container>
      </el-col>
@@ -44,15 +52,48 @@
</template>
<script>
import {getAuthTree,getUsedTemplateByClassifyOid,getCodeRule} from '@/api/code/codeApply.js'
import {getAuthTree,getUsedTemplateByClassifyOid,getCodeRule,addSaveCode} from '@/api/code/codeApply.js'
export default {
  name: "codeApply",
  components: { FormTemplate: () => import('@/components/FormTemplate/FormTemplate') },
  data() {
    return {
      defaultKeys: [
        "oid",
        "id",
        "name",
        "description",
        "revisionoid",
        "nameoid",
        "btmname",
        "lastr",
        "firstr",
        "lastv",
        "firstv",
        "creator",
        "createtime",
        "lastModifier",
        "lastmodifytime",
        "revisionrule",
        "revisionseq",
        "revisionvalue",
        "versionrule",
        "versionseq",
        "versionvalue",
        "lcstatus",
        "ts",
        "owner",
        "checkinby",
        "checkintime",
        "checkoutby",
        "checkouttime",
        "copyfromversion",
        "secretgrade",
      ],
      codeClassifyOid:'',
      type:'add',
      status:'code',
      TreeValue:'',
      dialogVisible:true,
      setForm:{},
@@ -61,6 +102,8 @@
      activeName: "codeApply",
      showCodeApply: false,
      eventList:[],
      showResembleQuery:false,
      hasResemble:false,
      form: {},
      TreeData:[],
      TreeOption: {
@@ -110,6 +153,106 @@
    this.getTreeData()
  },
  methods:{
    async submit() {
      // 进行表单校验
      const formValidate = await this.$refs.FormTemplate.validate();
      if (!formValidate) return;
      let codeValidate = true;
      // 进行码值申请校验
      // if (this.showCodeApply) {
      //   codeValidate = await this.$refs.CodeApply.validate();
      //   if (!codeValidate) {
      //     this.activeName = "codeApply";
      //     return false;
      //   }
      // }
      let resembleQueryList = [];
      if (this.showResembleQuery && this.$refs.resembleQueryRef) {
        // 进行相似项查询
        resembleQueryList = await this.$refs.resembleQueryRef.resembleQuery(
          this.form
        );
      }
      if (resembleQueryList.length > 0) {
        await this.$confirm(
          `该物料已有${resembleQueryList.length}条相似数据,是否继续保存?`,
          "需要您确认",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        );
      }
      // 排除一些字段
      const noData = [
        "jiliangdwname",
        "materialtypeText",
        "morengongysname",
        "$caigouwl",
        "$xiaoshouwl",
        "$shifoupihaoguanli",
        "lcstatus_text",
        "hesuanfenleiname",
        "$kucunwl",
        "oldcode",
        "lastmodifier"
      ];
      let resForm = {};
      const { defaultValue, formValue } = this.getDefaultValueAndFormValues(
        this.form
      );
      noData.forEach((item) => {
        this.$delete(formValue, item);
      });
      const keys = Object.keys(formValue);
      keys.forEach((item, index) => {
        keys.forEach((itm, idx) => {
          if ((item === ('$' + itm)) && idx !== index) {
            this.$delete(formValue, keys[index]);
          }
        })
      });
      resForm.data = formValue;
      resForm = Object.assign({}, resForm, defaultValue);
      resForm.secDTOList = this.secVOList.map((item) => {
        return {
          secOid: item.oid,
          secValue: this.codeApplyForm[item.oid],
        };
      });
      resForm.codeClassifyOid = this.codeClassifyOid;
      resForm.codeRuleOid = this.codeRuleOid;
      resForm.templateOid = this.templateOid;
      // this.$emit("submit", resForm);
      addSaveCode(resForm).then(res => {
        this.$nextTick(() => {
          this.addvisible = false;
          this.$message.success("保存成功");
          this.onLoad()
        })
      })
      console.log(resForm)
    },
    getDefaultValueAndFormValues(form) {
      let defaultValue = {};
      let formValue = {};
      for (const key in form) {
        if (Object.hasOwnProperty.call(form, key)) {
          const element = form[key];
          if (this.defaultKeys.includes(key)) {
            defaultValue[key] = element;
          } else {
            formValue[key] = element;
          }
        }
      }
      return {
        defaultValue,
        formValue,
      };
    },
    getFormData(form) {
      this.form = form;
    },
@@ -139,14 +282,28 @@
      });
    },
    nodeClick(row){
      // console.log(row)
      console.log(row)
      this.TreeValue=row.text.split(" ")[0].trim();
      this.codeClassifyOid = row.oid;
      getUsedTemplateByClassifyOid({ 'codeClassifyOid': this.codeClassifyOid,templateOid:' 97e979919a1f1dca67290e85fee22688' }).then((res) => {
        console.log('===res',res)
        if (res.data.code === 200) {
        if (res.status === 200) {
          this.hasResemble =
            res.data.resembleTableVO &&
            res.data.resembleTableVO.cols &&
            res.data.resembleTableVO.cols.length > 0;
          this.resembleTableColumn = res.data.resembleTableVO.cols || [];
          if (this.hasResemble) {
            this.activeName = "resembleQuery";
            this.showResembleQuery = true;
          } else {
            this.showResembleQuery = false;
          }
          this.$nextTick(() => {
            this.eventList=res.data.data.attributes
            this.$refs.FormTemplate.templateRender(
              res.data.formDefineVO.items
            );
            this.eventList=res.data.templateVO.attributes
            // this.$refs.FormTemplate.$emit('eventList',  res.data.templateVO.attributes);
            if (Object.keys(this.setForm).length > 0) {
              this.$refs.FormTemplate.form = this.setForm;