From 92ff846fb659c62037a32b1d8c15eae9df9d9b54 Mon Sep 17 00:00:00 2001
From: zenglf <18502938215@163.com>
Date: 星期一, 18 九月 2023 13:24:30 +0800
Subject: [PATCH] Merge branch 'develop' of http://117.34.109.166:18448/r/vue_mdc_430

---
 src/views/spare/modules/sparePart/SparePartModel.vue |  532 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 532 insertions(+), 0 deletions(-)

diff --git a/src/views/spare/modules/sparePart/SparePartModel.vue b/src/views/spare/modules/sparePart/SparePartModel.vue
new file mode 100644
index 0000000..223f820
--- /dev/null
+++ b/src/views/spare/modules/sparePart/SparePartModel.vue
@@ -0,0 +1,532 @@
+<template>
+  <a-modal
+    :title="title"
+    :width="1000"
+    :visible="visible"
+    :maskClosable="false"
+    :confirmLoading="confirmLoading"
+    :okButtonProps="{ props: {disabled: disableSubmit} }"
+    @ok="handleOk"
+    @cancel="handleCancel"
+    cancelText="鍏抽棴"
+  >
+    <a-spin :spinning="confirmLoading">
+      <a-form :form="form">
+        <a-row style="width: 100%">
+
+        </a-row>
+        <a-row style="width: 100%">
+          <a-col :span="24 / 2  ">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="澶囦欢缂栫爜"
+            >
+              <a-input
+                placeholder="灏嗙敱绯荤粺鐢熸垚"
+                v-decorator="['num', validatorRules.num]"
+              />
+            </a-form-item>
+          </a-col>
+          <a-col :span="24 / 2 ">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="澶囦欢鍚嶇О"
+            >
+              <a-input
+                placeholder="璇疯緭鍏ュ浠跺悕绉�"
+                v-decorator="['name', validatorRules.name]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row style="width: 100%">
+          <a-col :span="24 / 2">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鍨嬪彿缂栫爜"
+            >
+              <a-input
+                placeholder="璇疯緭鍏ュ瀷鍙风紪鐮�"
+                v-decorator="['model', validatorRules.model]"
+              />
+            </a-form-item>
+          </a-col>
+
+          <a-col :span="24 / 2  ">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="瑙勬牸"
+            >
+              <a-input
+                placeholder="璇疯緭鍏ヨ鏍�"
+                v-decorator="['specification', validatorRules.specification]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row style="width: 100%">
+          <a-col :span="24 / 2">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鍒堕�犲晢"
+            >
+              <j-dict-select-tag
+                allow-clear
+                :disabled="disableSubmit"
+                :placeholder="disableSubmit?'':'璇烽�夋嫨鍒堕�犲晢'"
+                :triggerChange="true"
+                dictCode="mom_base_constructor,name,id,status!='0' and del_flag!='1'"
+                v-decorator="['constructorId', validatorRules.constructorId]"
+              />
+            </a-form-item>
+          </a-col>
+          <a-col :span="24 / 2">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鍗曚綅"
+            >
+              <j-dict-select-tag
+                allow-clear
+                :disabled="disableSubmit"
+                :placeholder="disableSubmit?'':'璇烽�夋嫨鍗曚綅'"
+                :triggerChange="true"
+                dictCode="mom_base_unit,name,id,status!='0' and del_flag!='1'"
+                v-decorator="['mainUnitId', validatorRules.mainUnitId]"
+                @change="(e)=>handle2Change(e)"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row style="width: 100%">
+<!--          <a-col :span="24 / 2">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="杈呭崟浣�"
+            >
+              <a-select
+                :placeholder="disableSubmit?'':'璇烽�夋嫨杈呭崟浣�'"
+                :options="this.auxiliaryUnits"
+                style="width: 100%"
+                :disabled="disableSubmit"
+                v-decorator="['auxiliaryUnitId', validatorRules.auxiliaryUnitId]"
+                @change="(e)=>handle3Change(e)"
+              />
+            </a-form-item>
+          </a-col>-->
+          <a-col :span="24 / 2  ">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鏈夋晥鏈�"
+            >
+              <a-input-number
+                style="width: 100%"
+                placeholder="璇疯緭鍏ユ湁鏁堟湡"
+                v-decorator="['validityPeriod', validatorRules.validityPeriod]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+<!--        <a-row style="width: 100%">
+          &lt;!&ndash; hidden &ndash;&gt;
+          <a-col :span="24 / 2  ">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鎹㈢畻姣斾緥"
+            >
+              <a-input
+                style="width: 100%"
+                placeholder="璇疯緭鍏ユ崲绠楁瘮渚�"
+                v-decorator="['conversionRatio', validatorRules.conversionRatio]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>-->
+        <a-row style="width: 100%">
+          <a-col :span="24 / 2">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鏈夋晥鏈熷崟浣�"
+            >
+              <j-dict-select-tag
+                allow-clear
+                :disabled="disableSubmit"
+                :placeholder="disableSubmit?'':'璇烽�夋嫨鏈夋晥鏈熷崟浣�'"
+                :triggerChange="true"
+                dictCode="mom_base_unit,name,id,status!='0' and del_flag!='1'"
+                v-decorator="['validityPeriodUnitId', validatorRules.validityPeriodUnitId]"
+              />
+            </a-form-item>
+          </a-col>
+          <a-col :span="24 / 2">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="搴撳瓨涓婇檺鍊�"
+            >
+              <a-input-number
+                style="width: 100%"
+                placeholder="璇疯緭鍏ユ湁鏁堟湡"
+                v-decorator="['inventoryUpperLimit', validatorRules.inventoryUpperLimit]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row style="width: 100%">
+          <a-col :span="24 / 2  ">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="搴撳瓨涓嬮檺鍊�"
+            >
+              <a-input-number
+                style="width: 100%"
+                placeholder="璇疯緭鍏ュ簱瀛樹笅闄愬��"
+                v-decorator="['inventoryLowerLimit', validatorRules.inventoryLowerLimit]"
+              />
+            </a-form-item>
+          </a-col>
+          <a-col :span="24 / 2">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="搴撳瓨棰勮涓嬮檺"
+            >
+              <a-input-number
+                style="width: 100%"
+                placeholder="璇疯緭鍏ュ簱瀛橀璀︿笅闄�"
+                v-decorator="['inventoryWarnLimit', validatorRules.inventoryWarnLimit]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row style="width: 100%">
+          <a-col :span="24 / 2">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="缁忔祹璁㈣揣閲�"
+            >
+              <a-input-number
+                style="width: 100%"
+                placeholder="璇疯緭鍏ョ粡娴庤璐ч噺"
+                v-decorator="['economicOrderQuantity', validatorRules.economicOrderQuantity]"
+              />
+            </a-form-item>
+          </a-col>
+
+          <a-col :span="24 / 2  ">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="閲囪喘鎻愬墠鏈�"
+            >
+              <a-input-number
+                style="width: 100%"
+                placeholder="璇疯緭鍏ラ噰璐彁鍓嶆湡"
+                v-decorator="['purchaseLeadTime', validatorRules.purchaseLeadTime]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="{ span: 3 }"
+              :wrapperCol="{ span: 21 }"
+              label="澶囨敞"
+            >
+              <a-textarea
+                allow-clear
+                :disabled="disableSubmit"
+                :placeholder="disableSubmit?'':'璇疯緭鍏ュ娉�'"
+                v-decorator="['remark', validatorRules.remark]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+
+      </a-form>
+    </a-spin>
+
+    <template slot="footer">
+      <a-button
+        :style="{marginRight: '8px'}"
+        @click="handleCancel"
+      >
+        鍏抽棴
+      </a-button>
+      <a-button
+        :disabled="disableSubmit || confirmLoading"
+        :loading="confirmLoading"
+        @click="handleOk"
+        type="primary"
+      >纭畾</a-button>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+import pick from 'lodash.pick'
+import { postAction, requestPut, getAction } from '@/api/manage'
+import { duplicateCheck } from '@/api/api'
+import moment from 'moment'
+import JImageUpload from '@/components/jeecg/JImage2Upload'
+import Vue from 'vue'
+
+export default {
+  name: 'SparePartModel',
+  components: {
+    JImageUpload
+  },
+  data() {
+    return {
+      title: "鎿嶄綔",
+      visible: false,
+      codeDisable: true,
+      disableSubmit: false,
+      sparePartCategoryId: '',
+      auxiliaryUnits: [],
+      model: {},
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 6 },
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 18 },
+      },
+      confirmLoading: false,
+      form: this.$form.createForm(this),
+      validatorRules: {
+        num: {
+          rules: [
+            // { required: true, message: '璇疯緭鍏ヨ澶囧垎绫荤紪鍙�!' },
+            { min: 2, max: 30, message: '闀垮害鍦� 2 鍒� 30 涓瓧绗�', trigger: 'blur' },
+            // { validator: this.validateNum },
+          ]
+        },
+        name: {
+          rules: [
+            { required: true, message: '璇疯緭鍏ヨ澶囧垎绫诲悕绉�!' },
+            { min: 2, max: 30, message: '闀垮害鍦� 2 鍒� 30 涓瓧绗�', trigger: 'blur' },
+          ]
+        },
+        remark: {
+          rules: [
+            { min: 0, max: 100, message: '闀垮害涓嶈秴杩� 100 涓瓧绗�', trigger: 'blur' },
+          ]
+        }
+      },
+      url: {
+        add: "/spare/sparePart/add",
+        edit: "/spare/sparePart/edit",
+        getAuxiliaryUnits: "/spare/sparePart/getAuxiliaryUnits",
+        getConversionRatio: "/spare/sparePart/getConversionRatio",
+        getNum: '/eam/sysIdentity/getNumNew',
+      },
+      //鏂板銆佺紪杈戙�佸垹闄ゃ�佹壒閲忓垹闄ゆ搷浣滄敼鍙樻暟鎹悗鍒锋柊鍏宠仈鐨勭粍浠剁殑鐩戝惉灞炴��
+      alterFlag: "",
+    }
+  },
+  created() {
+    // this.getSysDeparts()
+  },
+  methods: {
+    moment,
+
+    add() {
+      this.edit({});
+    },
+
+    edit(record) {
+      this.form.resetFields();
+      this.model = Object.assign({}, record);
+      this.visible = true;
+      this.disableSubmit = false;
+      this.auxiliaryUnits = record.auxiliaryUnits
+      this.$nextTick(() => {
+        this.form.setFieldsValue(pick(this.model,
+          'num',
+          'name',
+          'specification',
+          'model',
+          'constructorId',
+          'mainUnitId',
+          'auxiliaryUnitId',
+          'conversionRatio',
+          'validityPeriod',
+          'validityPeriodUnitId',
+          'inventoryUpperLimit',
+          'inventoryLowerLimit',
+          'economicOrderQuantity',
+          'purchaseLeadTime',
+          'inventoryWarnLimit',
+          'remark'));
+      });
+      if (record.id) {
+        this.codeDisable = true;
+      } else {
+        this.codeDisable = false;
+        // this.$nextTick(() => {
+        //   getAction(this.url.getNum, { type: 'SparePart', length: '4' }).then((res) => {
+        //     if (res.success) {
+        //       this.form.setFieldsValue({ num: res.message });
+        //     }
+        //   })
+        // });
+      }
+    },
+
+    close() {
+      this.$emit('close');
+      this.visible = false;
+    },
+
+    handleOk() {
+      const that = this;
+      // 瑙﹀彂琛ㄥ崟楠岃瘉
+      this.form.validateFields(async (err, values) => {
+        if (!err) {
+          that.confirmLoading = true;
+          let formData = Object.assign(this.model, values);
+          let obj;
+          if (!this.model.id) {
+            if(!formData.num){
+                await getAction(this.url.getNum, { type: 'SparePart', length: '4' }).then((res) => {
+                if (res.success) {
+                  formData.num = res.message;
+                }
+              });
+            }
+            formData.sparePartCategoryId = this.sparePartCategoryId
+            obj = postAction(this.url.add, formData);
+          } else {
+            obj = requestPut(this.url.edit, formData, { id: this.model.id });
+          }
+          obj.then((res) => {
+            if (res.success) {
+              that.$message.success(res.message);
+              that.$emit('ok');
+              that.alterFlag = new Date();
+            } else {
+              that.$message.warning(res.message);
+            }
+          }).finally(() => {
+            that.confirmLoading = false;
+            that.close();
+          })
+        }
+      })
+    },
+
+    handle2Change(val) {
+      this.auxiliaryUnits = [];
+      this.form.setFieldsValue({ "auxiliaryUnitId": null, "conversionRatio": null })
+      this.getAuxiliaryUnits(val);
+    },
+
+    getAuxiliaryUnits(mainUnitId) {
+      getAction(this.url.getAuxiliaryUnits, { mainUnitId: mainUnitId }).then((res) => {
+        if (res.success) {
+          this.auxiliaryUnits = res.result
+        }
+      })
+    },
+
+    handle3Change(val) {
+      let data = this.form.getFieldsValue(['mainUnitId']);
+      if (data.mainUnitId === "" || data.mainUnitId === null || data.mainUnitId === undefined) {
+        this.$message.warning("璇烽�夋嫨涓诲崟浣嶏紒");
+        return
+      }
+      this.form.setFieldsValue({ "conversionRatio": null })
+      getAction(this.url.getConversionRatio, { mainUnitId: data.mainUnitId, auxiliaryUnitId: val }).then((res) => {
+        if (res.success) {
+          this.form.setFieldsValue({ "conversionRatio": res.result })
+        }
+      })
+
+    },
+
+    handleCancel() {
+      this.close()
+    },
+
+    //楠岃瘉 缂栧彿
+    validateNum(rule, value, callback) {
+      var params = {
+        tableName: 'mom_eam_equipment',
+        fieldName: 'num',
+        fieldVal: value,
+        dataId: this.model.id,
+        //鏁版嵁搴撲腑瀛樺湪瀛楁del_flag骞朵娇鐢ㄨ瀛楁浣滀负鏈垹闄ょ瓥鐣ワ紝鐪熷垹闄わ細false 鍋囧垹闄わ細true
+        delFlag: '0',
+      };
+      duplicateCheck(params).then((res) => {
+        if (res.success) {
+          callback();
+        } else {
+          callback("缂栧彿宸插瓨鍦�!");
+        }
+      })
+    },
+
+    //楠岃瘉 鍚嶇О
+    validateName(rule, value, callback) {
+      var params = {
+        tableName: 'mom_eam_equipment',
+        fieldName: 'name',
+        fieldVal: value,
+        dataId: this.model.id,
+        //鏁版嵁搴撲腑瀛樺湪瀛楁del_flag骞朵娇鐢ㄨ瀛楁浣滀负鏈垹闄ょ瓥鐣ワ紝鐪熷垹闄わ細false 鍋囧垹闄わ細true
+        delFlag: '0',
+      };
+      duplicateCheck(params).then((res) => {
+        if (res.success) {
+          callback();
+        } else {
+          callback("鍚嶇О宸插瓨鍦�!");
+        }
+      })
+    },
+
+  },
+  watch: {
+    alterFlag() {
+      this.$bus.$emit('queryTreeData');
+    },
+  }
+}
+</script>
+
+<style scoped>
+.ant-btn {
+  padding: 0 10px;
+  margin-left: 3px;
+}
+
+.ant-form-item-control {
+  line-height: 0px;
+}
+
+/** 涓昏〃鍗曡闂磋窛 */
+.ant-form .ant-form-item {
+  margin-bottom: 10px;
+}
+
+/** Tab椤甸潰琛岄棿璺� */
+.ant-tabs-content .ant-form-item {
+  margin-bottom: 0px;
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.3