PhysicalInspection.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="form-wrap">
  3. <div class="cardwrap">
  4. <el-row :gutter="20">
  5. <el-col :span="24">
  6. <div class="title">
  7. <span class="desc">产品名称:</span>
  8. <span class="content">{{ productName }}</span>
  9. </div>
  10. </el-col>
  11. <el-form
  12. v-if="dict.type.physical_index.length > 0 && formShow"
  13. :model="dictForm"
  14. ref="formRef"
  15. label-width="120px"
  16. :inline="true"
  17. size="normal"
  18. >
  19. <el-col
  20. v-for="item of dict.type.physical_index"
  21. :key="item.value"
  22. :span="12"
  23. >
  24. <el-form-item :label="item.label">
  25. <el-input
  26. @input="change()"
  27. v-model="dictForm[item.value]"
  28. ></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="12">
  32. <el-form-item label="备注">
  33. <el-input type="textarea" v-model="dictForm.remark"></el-input>
  34. </el-form-item>
  35. </el-col>
  36. </el-form>
  37. </el-row>
  38. <div class="btn">
  39. <el-button
  40. :disabled="isAddSuccess && !isEdit"
  41. class="mt10"
  42. type="primary"
  43. size="default"
  44. @click="record"
  45. >{{ isEdit ? "确认修改" : "记录" }}</el-button
  46. >
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import getNodeSequence from "@/utils/bpmn/getNodeSequence";
  53. import { xmlStr2XmlObj } from "@/utils/bpmn/xml";
  54. import { mapState } from "vuex";
  55. import { v4 as uuidv4 } from "uuid";
  56. import {
  57. addQualityInspectionCertificate,
  58. editQualityInspectionCertificate,
  59. addInspectionList,
  60. updateInspectionList,
  61. } from "@/api/bussiness/bpmExcuteProcess";
  62. import moment from "moment";
  63. import { getDicts } from "@/api/system/dict/data";
  64. export default {
  65. name: "PhysicalInspection",
  66. props: ["formData", "row"],
  67. dicts: ["physical_index"],
  68. components: {},
  69. data() {
  70. return {
  71. saleProductsData: {},
  72. isAddSuccess: false,
  73. productName: "",
  74. productNo: "",
  75. saleProductNo: "",
  76. inspectionId: "",
  77. remark: "",
  78. rowData: {},
  79. isEdit: false,
  80. inspectionListNo: "",
  81. dictData: [],
  82. dictForm: {
  83. remark: "",
  84. },
  85. tableData: [
  86. {
  87. productName: "",
  88. productNo: "",
  89. // 物理指标
  90. intensity: "", //强度
  91. elongation: "", //伸长率
  92. titer: "", //纤度
  93. oilContent: "", //含油率
  94. crimpRate: "", //卷缩率
  95. boilingWaterShrinkage: "", //沸水收缩率
  96. // 外观指标
  97. fuzz: "", //毛丝
  98. coilWire: "", //圈丝
  99. arachnoidSilk: "", //蛛网丝
  100. takeShapeBadness: "", //成型不良
  101. oilFree: "", //无油
  102. chromaticAberrationWire: "", //色差丝
  103. filaments: "", //污丝
  104. },
  105. ],
  106. formShow: true,
  107. };
  108. },
  109. watch: {
  110. myFormData: {
  111. immediate: true,
  112. deep: true,
  113. async handler(val) {
  114. console.log(val);
  115. this.saleProductsData = val.resultMap.saleProducts.resultMap;
  116. await this.initFormInfo(); //初始化表单数据
  117. this.isEdit = Object.keys(val.resultMap.inspectionList.resultMap).length
  118. ? true
  119. : false;
  120. let { product_name, product_no, sale_product_no } =
  121. val.resultMap.saleProducts.resultMap;
  122. this.productName = product_name;
  123. this.productNo = product_no;
  124. this.saleProductNo = sale_product_no;
  125. if (this.isEdit) {
  126. //第二次修改
  127. this.inspectionListNo =
  128. val.resultMap.inspectionList.resultMap.inspection_list_no;
  129. this.dictForm.remark = val.resultMap.inspectionList.resultMap.remark;
  130. this.inspectionId = val.resultMap.inspectionList.resultMap.id;
  131. let fieldList = val.resultMap.inspectionListInfo.map(
  132. (item) => item.resultMap
  133. );
  134. this.dictData.forEach((item) => {
  135. let prop = item.value;
  136. let target = fieldList.find((item) => item.indexName == prop);
  137. if (target) {
  138. this.dictForm[prop] = target.indexContent;
  139. item.id = target.id;
  140. } else {
  141. console.log("没有找到");
  142. }
  143. });
  144. this.formShow = false;
  145. this.$nextTick(() => {
  146. this.formShow = true;
  147. });
  148. }
  149. },
  150. },
  151. myRow: {
  152. immediate: true,
  153. deep: true,
  154. handler(val) {
  155. this.rowData = val;
  156. },
  157. },
  158. },
  159. computed: {
  160. myFormData() {
  161. return this.formData;
  162. },
  163. myRow() {
  164. return this.row;
  165. },
  166. ...mapState({
  167. nickName: (state) => state.user.nickName,
  168. }),
  169. },
  170. created() {},
  171. methods: {
  172. change() {
  173. this.$forceUpdate(); //强制刷新
  174. },
  175. // 初始化表单数据
  176. async initFormInfo() {
  177. try {
  178. let res = await getDicts("physical_index");
  179. if (res.code == 200) {
  180. console.log(res.data);
  181. this.dictData = res.data.map((item) => {
  182. return {
  183. value: item.dictValue,
  184. label: item.dictLabel,
  185. data: item,
  186. };
  187. });
  188. }
  189. } catch (error) {}
  190. console.log(this.dict.type.physical_index);
  191. this.dict.type.physical_index.map((item) => {
  192. // this.dictForm[item.key] = "";
  193. this.$set(this.dictForm, item.key, "");
  194. });
  195. this.dictForm.remark = "";
  196. },
  197. // 记录质检结果
  198. async record() {
  199. let uuid = uuidv4();
  200. let { bepTaskName, bepTaskKey, benTaskNodeKey } = this.rowData;
  201. let { lot_number, materieColorNumber } = this.saleProductsData;
  202. let payLoad = {
  203. id: this.isEdit ? this.inspectionId : null,
  204. inspectionListNo: this.isEdit ? this.inspectionListNo : uuid, //检验单编号
  205. saleNo: bepTaskName, // 销售单编号
  206. taskProcessKey: bepTaskKey, //任务编码
  207. taskNodeKey: benTaskNodeKey, //任务节点编码
  208. inspectionTime: moment(new Date()).format("YYYY-MM-DD HH:mm:ss"), //检验时间
  209. inspectionPersonnel: this.nickName, //检验人员
  210. remark: this.dictForm.remark, //备注
  211. indexType: "1", //1:物理指标 2:外观指标
  212. saleProductNo: this.saleProductNo, //销售产品编号
  213. inspectionListInfoList: [],
  214. lotNumber: lot_number,
  215. colourNumber: materieColorNumber,
  216. };
  217. // payLoad.inspectionListInfo = {
  218. // ...this.dictForm,
  219. // taskProcessKey: bepTaskKey, //任务编码
  220. // taskNodeKey: benTaskNodeKey, //任务节点编码
  221. // };
  222. payLoad.inspectionListInfoList = this.dict.type.physical_index.map(
  223. (item) => {
  224. if (this.isEdit) {
  225. return {
  226. id: this.dictData.find((i) => i.value == item.value).id,
  227. inspectionListNo: this.inspectionListNo, //检验单编号
  228. productNo: this.productNo,
  229. productName: this.productName,
  230. indexName: item.value,
  231. indexContent: this.dictForm[item.value],
  232. };
  233. } else {
  234. return {
  235. inspectionListNo: uuid, //检验单编号
  236. productNo: this.productNo,
  237. productName: this.productName,
  238. indexName: item.value,
  239. indexContent: this.dictForm[item.value],
  240. };
  241. }
  242. }
  243. );
  244. console.log(payLoad);
  245. // return;
  246. // payLoad.inspectionListInfo = this.tableData.map((item) => {
  247. // return {
  248. // inspectionListNo: payLoad.inspectionList.inspectionListNo,
  249. // ...item,
  250. // taskProcessKey: bepTaskKey, //任务编码
  251. // taskNodeKey: benTaskNodeKey, //任务节点编码
  252. // };
  253. // });
  254. try {
  255. let apiFun = this.isEdit ? updateInspectionList : addInspectionList;
  256. let res = await apiFun(payLoad);
  257. if (res.code == 200) {
  258. let msg = this.isEdit ? "修改成功" : "添加成功";
  259. if (!this.isEdit) {
  260. this.isAddSuccess = true;
  261. }
  262. this.$message.success(msg);
  263. } else {
  264. this.$message.error(res.msg);
  265. }
  266. } catch (error) {
  267. console.log(error);
  268. }
  269. },
  270. async getFormData() {
  271. let formData = {
  272. flag: false,
  273. msg: "",
  274. };
  275. return {
  276. flag: true,
  277. data: {},
  278. };
  279. },
  280. },
  281. };
  282. </script>
  283. <style scoped lang="scss">
  284. .title {
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. font-size: 20px;
  289. font-weight: 700;
  290. margin-bottom: 10px;
  291. .desc {
  292. margin-right: 10px;
  293. }
  294. }
  295. .btn {
  296. display: flex;
  297. flex-direction: row-reverse;
  298. }
  299. .remark {
  300. display: flex;
  301. margin-top: 10px;
  302. .label {
  303. display: block;
  304. width: 100px;
  305. text-align: center;
  306. }
  307. }
  308. </style>
  309. ./PhysicalInSpection.vue