123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- <template>
- <div class="form-wrap">
- <div class="cardwrap">
- <el-row :gutter="20">
- <el-col :span="24">
- <div class="title">
- <span class="desc">产品名称:</span>
- <span class="content">{{ productName }}</span>
- </div>
- </el-col>
- <el-form
- v-if="dict.type.physical_index.length > 0 && formShow"
- :model="dictForm"
- ref="formRef"
- label-width="120px"
- :inline="true"
- size="normal"
- >
- <el-col
- v-for="item of dict.type.physical_index"
- :key="item.value"
- :span="12"
- >
- <el-form-item :label="item.label">
- <el-input
- @input="change()"
- v-model="dictForm[item.value]"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="备注">
- <el-input type="textarea" v-model="dictForm.remark"></el-input>
- </el-form-item>
- </el-col>
- </el-form>
- </el-row>
- <div class="btn">
- <el-button
- :disabled="isAddSuccess && !isEdit"
- class="mt10"
- type="primary"
- size="default"
- @click="record"
- >{{ isEdit ? "确认修改" : "记录" }}</el-button
- >
- </div>
- </div>
- </div>
- </template>
- <script>
- import getNodeSequence from "@/utils/bpmn/getNodeSequence";
- import { xmlStr2XmlObj } from "@/utils/bpmn/xml";
- import { mapState } from "vuex";
- import { v4 as uuidv4 } from "uuid";
- import {
- addQualityInspectionCertificate,
- editQualityInspectionCertificate,
- addInspectionList,
- updateInspectionList,
- } from "@/api/bussiness/bpmExcuteProcess";
- import moment from "moment";
- import { getDicts } from "@/api/system/dict/data";
- export default {
- name: "PhysicalInspection",
- props: ["formData", "row"],
- dicts: ["physical_index"],
- components: {},
- data() {
- return {
- saleProductsData: {},
- isAddSuccess: false,
- productName: "",
- productNo: "",
- saleProductNo: "",
- inspectionId: "",
- remark: "",
- rowData: {},
- isEdit: false,
- inspectionListNo: "",
- dictData: [],
- dictForm: {
- remark: "",
- },
- tableData: [
- {
- productName: "",
- productNo: "",
- // 物理指标
- intensity: "", //强度
- elongation: "", //伸长率
- titer: "", //纤度
- oilContent: "", //含油率
- crimpRate: "", //卷缩率
- boilingWaterShrinkage: "", //沸水收缩率
- // 外观指标
- fuzz: "", //毛丝
- coilWire: "", //圈丝
- arachnoidSilk: "", //蛛网丝
- takeShapeBadness: "", //成型不良
- oilFree: "", //无油
- chromaticAberrationWire: "", //色差丝
- filaments: "", //污丝
- },
- ],
- formShow: true,
- };
- },
- watch: {
- myFormData: {
- immediate: true,
- deep: true,
- async handler(val) {
- console.log(val);
- this.saleProductsData = val.resultMap.saleProducts.resultMap;
- await this.initFormInfo(); //初始化表单数据
- this.isEdit = Object.keys(val.resultMap.inspectionList.resultMap).length
- ? true
- : false;
- let { product_name, product_no, sale_product_no } =
- val.resultMap.saleProducts.resultMap;
- this.productName = product_name;
- this.productNo = product_no;
- this.saleProductNo = sale_product_no;
- if (this.isEdit) {
- //第二次修改
- this.inspectionListNo =
- val.resultMap.inspectionList.resultMap.inspection_list_no;
- this.dictForm.remark = val.resultMap.inspectionList.resultMap.remark;
- this.inspectionId = val.resultMap.inspectionList.resultMap.id;
- let fieldList = val.resultMap.inspectionListInfo.map(
- (item) => item.resultMap
- );
- this.dictData.forEach((item) => {
- let prop = item.value;
- let target = fieldList.find((item) => item.indexName == prop);
- if (target) {
- this.dictForm[prop] = target.indexContent;
- item.id = target.id;
- } else {
- console.log("没有找到");
- }
- });
- this.formShow = false;
- this.$nextTick(() => {
- this.formShow = true;
- });
- }
- },
- },
- myRow: {
- immediate: true,
- deep: true,
- handler(val) {
- this.rowData = val;
- },
- },
- },
- computed: {
- myFormData() {
- return this.formData;
- },
- myRow() {
- return this.row;
- },
- ...mapState({
- nickName: (state) => state.user.nickName,
- }),
- },
- created() {},
- methods: {
- change() {
- this.$forceUpdate(); //强制刷新
- },
- // 初始化表单数据
- async initFormInfo() {
- try {
- let res = await getDicts("physical_index");
- if (res.code == 200) {
- console.log(res.data);
- this.dictData = res.data.map((item) => {
- return {
- value: item.dictValue,
- label: item.dictLabel,
- data: item,
- };
- });
- }
- } catch (error) {}
- console.log(this.dict.type.physical_index);
- this.dict.type.physical_index.map((item) => {
- // this.dictForm[item.key] = "";
- this.$set(this.dictForm, item.key, "");
- });
- this.dictForm.remark = "";
- },
- // 记录质检结果
- async record() {
- let uuid = uuidv4();
- let { bepTaskName, bepTaskKey, benTaskNodeKey } = this.rowData;
- let { lot_number, materieColorNumber } = this.saleProductsData;
- let payLoad = {
- id: this.isEdit ? this.inspectionId : null,
- inspectionListNo: this.isEdit ? this.inspectionListNo : uuid, //检验单编号
- saleNo: bepTaskName, // 销售单编号
- taskProcessKey: bepTaskKey, //任务编码
- taskNodeKey: benTaskNodeKey, //任务节点编码
- inspectionTime: moment(new Date()).format("YYYY-MM-DD HH:mm:ss"), //检验时间
- inspectionPersonnel: this.nickName, //检验人员
- remark: this.dictForm.remark, //备注
- indexType: "1", //1:物理指标 2:外观指标
- saleProductNo: this.saleProductNo, //销售产品编号
- inspectionListInfoList: [],
- lotNumber: lot_number,
- colourNumber: materieColorNumber,
- };
- // payLoad.inspectionListInfo = {
- // ...this.dictForm,
- // taskProcessKey: bepTaskKey, //任务编码
- // taskNodeKey: benTaskNodeKey, //任务节点编码
- // };
- payLoad.inspectionListInfoList = this.dict.type.physical_index.map(
- (item) => {
- if (this.isEdit) {
- return {
- id: this.dictData.find((i) => i.value == item.value).id,
- inspectionListNo: this.inspectionListNo, //检验单编号
- productNo: this.productNo,
- productName: this.productName,
- indexName: item.value,
- indexContent: this.dictForm[item.value],
- };
- } else {
- return {
- inspectionListNo: uuid, //检验单编号
- productNo: this.productNo,
- productName: this.productName,
- indexName: item.value,
- indexContent: this.dictForm[item.value],
- };
- }
- }
- );
- console.log(payLoad);
- // return;
- // payLoad.inspectionListInfo = this.tableData.map((item) => {
- // return {
- // inspectionListNo: payLoad.inspectionList.inspectionListNo,
- // ...item,
- // taskProcessKey: bepTaskKey, //任务编码
- // taskNodeKey: benTaskNodeKey, //任务节点编码
- // };
- // });
- try {
- let apiFun = this.isEdit ? updateInspectionList : addInspectionList;
- let res = await apiFun(payLoad);
- if (res.code == 200) {
- let msg = this.isEdit ? "修改成功" : "添加成功";
- if (!this.isEdit) {
- this.isAddSuccess = true;
- }
- this.$message.success(msg);
- } else {
- this.$message.error(res.msg);
- }
- } catch (error) {
- console.log(error);
- }
- },
- async getFormData() {
- let formData = {
- flag: false,
- msg: "",
- };
- return {
- flag: true,
- data: {},
- };
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .title {
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 20px;
- font-weight: 700;
- margin-bottom: 10px;
- .desc {
- margin-right: 10px;
- }
- }
- .btn {
- display: flex;
- flex-direction: row-reverse;
- }
- .remark {
- display: flex;
- margin-top: 10px;
- .label {
- display: block;
- width: 100px;
- text-align: center;
- }
- }
- </style>
- ./PhysicalInSpection.vue
|