From 3c6566a26c6bb6f68deed9f2c8e7b6eab1209134 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 28 八月 2026 15:42:42 +0800
Subject: [PATCH] feat(order): 添加产品检验项选择功能并增加导入导出功能 - 实现产品检验项的选择状态管理和计数显示功能 - 添加标准物质和设备管理模块的导入导出功能 - 新增导入模板下载和上传验证机制 - 调整表单验证规则,移除生产单位必填限制
---
src/views/business/productOrder/components/addOrder.vue | 337 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 242 insertions(+), 95 deletions(-)
diff --git a/src/views/business/productOrder/components/addOrder.vue b/src/views/business/productOrder/components/addOrder.vue
index 5b9c516..c880056 100644
--- a/src/views/business/productOrder/components/addOrder.vue
+++ b/src/views/business/productOrder/components/addOrder.vue
@@ -14,9 +14,13 @@
<el-select v-show="active==1" v-model="template" placeholder="涓嬪崟妯℃澘" size="small"
@change="selectInsOrderTemplateById">
<el-option v-for="(a, ai) in templates" :key="ai" :label="a.name" :value="a.id">
- <span style="float: left">{{ a.name }}</span>
- <i class="el-icon-delete" style="float: right; color: #66b1ff; font-size: 16px"
- @click.stop="handleDelete(a)"></i>
+ <div style="display: flex; align-items: center; justify-content: space-between;">
+ <span>{{ a.name }}</span>
+ <i class="el-icon-delete"
+ style="color: #66b1ff; font-size: 16px; cursor: pointer;"
+ @click.stop="handleDelete(a)">
+ </i>
+ </div>
</el-option>
</el-select>
<el-button v-show="active==1" size="small" @click="templateDia=true">
@@ -296,19 +300,27 @@
</template>
</el-table-column>
</el-table>
+ <div v-if="canSelectProduct" style="display: flex; align-items: center; gap: 12px; padding: 10px 0;">
+ <span>妫�娴嬭寖鍥达細</span>
+ <el-radio-group v-model="inspectionScope" size="small" @change="changeInspectionScope">
+ <el-radio-button label="all">鍏ㄩ儴妫�楠�</el-radio-button>
+ <el-radio-button label="specified">鎸囧畾妫�楠岄」</el-radio-button>
+ </el-radio-group>
+ <span>宸查�� {{ selectedProductCount }} / 鍏� {{ productList.length }} 椤�</span>
+ </div>
<el-table ref="productTable" v-loading="getProductLoad" :data="productList"
:row-class-name="tableRowClassName" border class="el-table"
:header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }"
max-height="400px" style="margin-bottom: 10px;" tooltip-effect="dark"
@select="selectOne" @selection-change="selectProduct" @select-all="handleAll">
- <el-table-column v-if="active==1" :selectable="selectable0" type="selection" width="65"></el-table-column>
+ <el-table-column v-if="canSelectProduct" :selectable="selectable0" type="selection" width="65"></el-table-column>
<el-table-column label="妫�楠岄」鍒嗙被" min-width="140" prop="inspectionItemClass" show-overflow-tooltip></el-table-column>
<el-table-column label="妫�楠岄」" min-width="140" prop="inspectionItem" show-overflow-tooltip>
<template slot="header" slot-scope="scope">
<div style="display: flex;align-items: center;flex-direction: column;font-size: 14px">
<span>妫�楠岄」</span>
<el-input
- v-if="active==1"
+ v-if="canSelectProduct"
v-model="inspectionItem"
placeholder="璇疯緭鍏�"
size="mini"
@@ -322,7 +334,7 @@
<div style="display: flex;align-items: center;flex-direction: column;font-size: 14px">
<span>妫�楠岄」瀛愰」</span>
<el-input
- v-if="active==1"
+ v-if="canSelectProduct"
v-model="inspectionItemSubclass"
placeholder="璇疯緭鍏�"
size="mini"
@@ -364,7 +376,7 @@
<div style="display: flex;align-items: center;flex-direction: column;font-size: 14px">
<span>璇曢獙鏂规硶</span>
<el-input
- v-if="active==1"
+ v-if="canSelectProduct"
v-model="methodS"
placeholder="璇疯緭鍏�"
size="mini"
@@ -459,10 +471,10 @@
</div>
</el-col>
<el-col v-if="distributeData.userId" :span="22" class="search_thing">
- <div class="search_label"><span class="required-span">* </span>璇曢獙瀹わ細</div>
+ <div class="search_label">璇曢獙瀹わ細</div>
<div class="search_input">
<el-select v-model="distributeData.sonLaboratory" filterable placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
- <el-option v-for="item in sonLaboratoryList" :key="item.value" :label="item.label" :value="item.value">
+ <el-option v-for="item in newJuLaboratoryList" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
@@ -587,7 +599,7 @@
} from "@/api/business/rawMaterialOrder";
import {
addInsOrder, addInsOrderTemplate, delInsOrderTemplate,
- getQuarterOnOrder, selectInsOrderTemplateById,
+ getQuarterOnOrder, judgeNotSpotCheckOrder, selectInsOrderTemplateById,
selectOrderManDay,
updateInsOrder,
upInsOrder,
@@ -598,6 +610,8 @@
import limsTable from "@/components/Table/lims-table.vue";
import {selectCustomPageList} from "@/api/system/customer";
import {mapGetters} from "vuex";
+import { bigEval } from "@/utils/bigEval";
+import {addQuarter, updateQuarterOnOrder} from "@/api/business/finishedProductSampling";
export default {
name: 'AddOrder',
@@ -607,9 +621,18 @@
AuxiliaryWireCore
},
computed:{
- ...mapGetters(["nickName"]),
+ ...mapGetters(["nickName", 'nameEn', 'userName']),
+ canSelectProduct() {
+ return this.active == 1 || (this.tabIndex == 4 && this.active == 2)
+ },
+ selectedProductCount() {
+ return this.productList.filter(item => item.state == 1).length
+ },
+ newJuLaboratoryList() {
+ return (this.dict.type.sys_sub_lab || []).filter(item => item.label === '鏂拌仛')
+ },
},
- dicts: ['check_type1', 'urgency_level', 'form_type', 'sample_status_list'],
+ dicts: ['check_type1', 'urgency_level', 'form_type', 'sample_status_list', 'sys_sub_lab'],
data() {
return {
active: '',
@@ -682,12 +705,6 @@
],
testQuantity: [
{ required: true, message: '璇峰~鍐欐娊妫�鏁伴噺', trigger: 'blur' }
- ],
- production: [
- { required: true, message: '璇峰~鍐欑敓浜у崟浣�', trigger: 'blur' }
- ],
- productionEn: [
- { required: true, message: '璇峰~鍐欑敓浜у崟浣岴N', trigger: 'blur' }
],
},
sample: {
@@ -790,13 +807,14 @@
quarterItemOptions: [], // 鏌ヨ瀛e害淇℃伅
specialStandardMethod: '',
isSpecial: false,
+ inspectionScope: 'all',
}
},
watch: {
- sampleList() {
- this.addObj.method = null
- this.productList = []
- },
+ // sampleList() {
+ // this.addObj.method = null
+ // this.productList = []
+ // },
productList: {
deep: true,
handler(val) {
@@ -842,6 +860,11 @@
this.currentId = this.$route.query.currentId
this.getUserNowData()
this.getInfo()
+ if(this.tabIndex==4&&this.active==2){
+ this.isSpecial = true
+ }else{
+ this.isSpecial = false
+ }
},
activated() {
this.active = this.$route.query.active
@@ -850,11 +873,41 @@
this.getInfo();
},
methods: {
+ /**
+ * 鑾峰彇灏忔暟鐨勬渶澶т綅鏁�
+ * @param number 鍨嬪彿鍙傛暟
+ * @param ask 瑕佹眰鍊�
+ * @param calcNum 璁$畻鍊�
+ */
+ getDecimalPlaces(number, ask, calcNum) {
+ console.log("璁$畻灏忔暟鐐�-->", number, ask, calcNum);
+ let count1 = 0;
+ let count2 = 0;
+ const reg = /(\d+\.)(\d+)/g;
+ let matches = [];
+ if (ask) {
+ matches = ask.match(reg);
+ }
+ if (
+ matches &&
+ matches.length > 0 &&
+ matches[0].toString().indexOf(".") > -1
+ ) {
+ count1 = matches[0].toString().split(".")[1].length;
+ }
+ if (number.toString().indexOf(".") > -1) {
+ count2 = number.toString().split(".")[1].length;
+ }
+ if (calcNum.toString().indexOf(".") > -1) {
+ const pointLength2 = calcNum.toString().split(".")[1].length;
+ count2 = count2 > pointLength2 ? count2 : pointLength2;
+ }
+ return count1 > count2 ? count1 : count2;
+ },
getInfo() {
this.selectStandardTreeList()
this.getAuthorizedPerson();
this.selectStandardMethods()
- this.getPrepareUser() // 澶嶅埗褰撳墠璐﹀彿浜轰负濮旀墭浜�
if (this.active != 1) {
// 鏌ョ湅/瀹℃牳娴佺▼
// 璇锋眰鎺ュ彛锛屽洖鏄炬暟鎹�
@@ -865,29 +918,26 @@
...res.data.insOrder
};
this.addObj.type = String(this.addObj.type)
- this.sampleList = this.HaveJson(res.data.sampleProduct);
- this.specialStandardMethod = this.sampleList[0].specialStandardMethod
- this.getProNum()
- this.addObj.sampleNum = this.sampleList.length
- this.$nextTick(() => {
- this.$refs.sampleTable.doLayout()
- if (this.addObj.sampleNum > 0) {
- this.$refs.sampleTable.setCurrentRow(this.sampleList[0], true)
- this.rowClick(this.sampleList[0])
- }
+ const samples = this.HaveJson(res.data.sampleProduct)
+ const loadSamples = this.canSelectProduct
+ ? Promise.all(samples.map(sample => this.loadSelectableProducts(sample)))
+ : Promise.resolve(samples)
+ loadSamples.then(sampleList => {
+ this.sampleList = sampleList
+ this.specialStandardMethod = this.sampleList[0].specialStandardMethod
+ this.getProNum()
+ this.addObj.sampleNum = this.sampleList.length
+ this.$nextTick(() => {
+ this.$refs.sampleTable.doLayout()
+ if (this.addObj.sampleNum > 0) {
+ this.$refs.sampleTable.setCurrentRow(this.sampleList[0], true)
+ this.rowClick(this.sampleList[0])
+ }
+ })
})
})
}
- if(this.tabIndex==4&&this.active==2){
- this.isSpecial = true
- }else{
- this.isSpecial = false
- }
- },
- getPrepareUser () {
- // this.addObj.prepareUser = JSON.parse(localStorage.getItem("user")).name;
- // this.addObj.prepareUserEn = JSON.parse(localStorage.getItem("user")).nameEn
- // this.addObj.prepareCode = JSON.parse(localStorage.getItem("user")).account
+
},
// 缂栬緫瑕佹眰鍊艰〃鏍�
editSpecial () {
@@ -1045,7 +1095,13 @@
let index = code.findIndex(b => m.includes(b))
if (index > -1) {
let arr = m.split(code[index]).filter(b => !!b)
- let num = eval(this.replaceAll(arr[0], symbolItem, value))
+ let calcNum = this.$Big(
+ bigEval(this.replaceAll(arr[0], symbolItem, value))
+ );
+ let num = calcNum.toFixed(
+ this.getDecimalPlaces(value, ask, calcNum)
+ );
+ // let num = eval(this.replaceAll(arr[0], symbolItem, value))
m = code[index] + '' + num
arr1.push(m)
}
@@ -1074,7 +1130,13 @@
let index = code.findIndex(b => ask.includes(b))
if (index > -1) {
let arr = ask.split(code[index]).filter(b => !!b)
- let num = eval(this.replaceAll(arr[0], symbolItem, value))
+ let calcNum = this.$Big(
+ bigEval(this.replaceAll(arr[0], symbolItem, value))
+ );
+ let num = calcNum.toFixed(
+ this.getDecimalPlaces(value, ask, calcNum)
+ );
+ // let num = eval(this.replaceAll(arr[0], symbolItem, value))
return code[index] + '' + num
}
}
@@ -1122,22 +1184,23 @@
if (this.tabIndex != 4) {
delete c.id
}
+ if (c.isNew) {
+ c.id = null
+ delete c.isNew
+ }
})
}
if (a.endModels) {
a.model = a.endModels
}
- a.insProduct = a.insProduct.filter(b=>b.state === 1)
+ if (!this.canSelectProduct || this.active == 1) {
+ a.insProduct = a.insProduct.filter(b=>b.state === 1)
+ }
})
let projectNum = this.totalArr.filter(a => a.state == 1).length
if(projectNum==0){
- this.$confirm('妫�楠岄」鐩负绌猴紝鏄惁纭鎻愪氦?', "鎻愮ず", {
- confirmButtonText: "纭畾",
- cancelButtonText: "鍙栨秷",
- type: "warning"
- }).then(() => {
- this.saveMethod(sampleList)
- }).catch(() => {})
+ this.$message.warning('璇疯嚦灏戦�夋嫨涓�涓楠岄」')
+ return
}else{
let isRTS = this.totalArr.find(a => a.ask != null && this.symbolList.find(b=>a.ask.includes(b)) && a.state == 1)
if (isRTS) {
@@ -1162,12 +1225,18 @@
if (this.tabIndex != 4) {
delete c.id
}
+ if (c.isNew) {
+ c.id = null
+ delete c.isNew
+ }
})
}
if (a.endModels) {
a.model = a.endModels
}
- a.insProduct = a.insProduct.filter(b=>b.state === 1)
+ if (!this.canSelectProduct || this.active == 1) {
+ a.insProduct = a.insProduct.filter(b=>b.state === 1)
+ }
})
this.saveMethod(sampleList)
}else{
@@ -1260,36 +1329,62 @@
}
},
saveMethod(sampleList){
- this.saveLoad = true
if (this.addObj.quarterItemId) {
this.addObj.quarterItemId = this.addObj.quarterItemId[1]
}
- if(this.tabIndex==4&&this.active==2){
- if (this.addObj.createTime) {
- delete this.addObj.createTime
- }
- // 閫�鍥炲悗鎻愪氦
- updateInsOrder({insOrder: this.addObj, sampleProduct: sampleList}).then(res => {
- this.saveLoad = false
- this.$message.success('宸叉彁浜�')
- this.bsm3Dia = false;
- this.closeOpenPage()
- }).catch(e=>{
- this.saveLoad = false
- })
- }else{
- // 甯歌鎻愪氦
- addInsOrder({insOrder: this.addObj, sampleList: sampleList}).then(res => {
- this.saveLoad = false
- this.$message.success('宸叉彁浜�')
- this.bsm3Dia = false;
- this.closeOpenPage()
- }).catch(e=>{
- this.saveLoad = false
- })
+ if (this.addObj.createTime) {
+ delete this.addObj.createTime
}
-
+ if (this.addObj.orderType === '鎶芥') {
+ judgeNotSpotCheckOrder({ insOrder: this.addObj, sampleList: sampleList }).then(res => {
+ if (res.data === true) {
+ this.saveData(sampleList);
+ } else {
+ // const message = res.message.replace(/\n/g, '<br>');
+ this.$confirm(res.message, '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning',
+ dangerouslyUseHTMLString: true, // 馃憟 鍏抽敭鐐癸細鍏佽 HTML
+ message: res.message // 杩欓噷涔熷彲浠ョ渷鐣ワ紝鍥犱负绗簩涓弬鏁版槸 title锛岀涓変釜鏄� options
+ }).then(() => {
+ this.saveData(sampleList);
+ }).catch(() => {
+ this.$message({
+ type: 'info',
+ message: '宸插彇娑�'
+ });
+ });
+ }
+ });
+ } else {
+ this.saveData(sampleList)
+ }
},
+ saveData(sampleList) {
+ this.saveLoad = true
+ if(this.tabIndex==4&&this.active==2){
+ // 閫�鍥炲悗鎻愪氦
+ updateInsOrder({insOrder: this.addObj, sampleProduct: sampleList}).then(res => {
+ this.saveLoad = false
+ this.$message.success('宸叉彁浜�')
+ this.bsm3Dia = false;
+ this.closeOpenPage()
+ }).catch(e=>{
+ this.saveLoad = false
+ })
+ }else{
+ // 甯歌鎻愪氦
+ addInsOrder({insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList}).then(res => {
+ this.saveLoad = false
+ this.$message.success('宸叉彁浜�')
+ this.bsm3Dia = false;
+ this.closeOpenPage()
+ }).catch(e=>{
+ this.saveLoad = false
+ })
+ }
+ },
upInsOrderOfState(state) {
if (state == 1) {
this.saveLoad = true
@@ -1309,6 +1404,7 @@
this.distributeData.appointed = ress.data
})
setTimeout(() => {
+ this.distributeData.sonLaboratory = this.newJuLaboratoryList.length > 0 ? this.newJuLaboratoryList[0].value : ''
this.issuedDialogVisible = true;
}, 1000)
})
@@ -1325,10 +1421,6 @@
}
if (this.distributeData.userId == null || this.distributeData.userId == '') {
this.$message.error('鎸囨淳浜哄憳鏈~鍐�')
- return
- }
- if (this.distributeData.userId&&(this.distributeData.sonLaboratory== null ||this.distributeData.sonLaboratory== '')) {
- this.$message.error('璇曢獙瀹ゆ湭濉啓')
return
}
this.upLoad = true;
@@ -1348,6 +1440,9 @@
})
},
getUserNowData() {
+ this.addObj.prepareUser = this.nickName
+ this.addObj.prepareUserEn = this.nameEn
+ this.addObj.prepareCode = this.userName
getUserNow().then(res => {
let selects = res.data
if (selects == null) return
@@ -1357,8 +1452,8 @@
this.addObj.code = selects.code
this.addObj.phone = selects.phone
this.addObj.companyId = selects.departId
- this.addObj.production = '涓ぉ绉戞妧瑁呭鐢电紗鏈夐檺鍏徃'
- this.addObj.productionEn = 'Zhongtian Technology Industrial Wire&Cable System CO.,LTD'
+ this.addObj.production = ''
+ this.addObj.productionEn = ''
if(this.active==1){
this.selectInsOrderTemplate()
}
@@ -1555,6 +1650,9 @@
}
this.productList = row.insProduct
this.productList0 = JSON.parse(JSON.stringify(this.productList))
+ this.inspectionScope = this.productList.length === 0
+ ? (this.active == 1 ? 'all' : 'specified')
+ : (this.productList.every(item => item.state == 1) ? 'all' : 'specified')
setTimeout(() => {
this.productList.forEach(a => {
if (a.state == 1) {
@@ -1624,6 +1722,9 @@
})
this.changeProductList0()
this.currentMethod.insProduct = this.productList0
+ this.inspectionScope = this.productList.length > 0 && this.productList.every(item => item.state == 1)
+ ? 'all'
+ : 'specified'
this.getProNum()
},
permute(nums) {
@@ -1744,7 +1845,7 @@
conductorType: row.conductorType,
}).then(res => {
res.data.forEach(a => {
- a.state = 0
+ a.state = this.inspectionScope === 'all' ? 1 : 0
})
row.insProduct = this.HaveJson(res.data)
this.getProductLoad = false
@@ -1759,6 +1860,9 @@
this.productList.forEach(a => {
if (a.state == 1) this.toggleSelection(a)
})
+ if (this.inspectionScope === 'all') {
+ this.handleAll(this.productList.filter(item => this.selectable0(item)))
+ }
}, 200)
})
},
@@ -1806,7 +1910,7 @@
factory: selectTreeList.join(" - "),
}).then(res => {
res.data.forEach(a => {
- a.state = 0
+ a.state = this.inspectionScope === 'all' ? 1 : 0
})
row.insProduct = this.HaveJson(res.data)
this.getProductLoad = false
@@ -1817,6 +1921,9 @@
this.productList.forEach(a => {
if (a.state == 1) this.toggleSelection(a)
})
+ if (this.inspectionScope === 'all') {
+ this.handleAll(this.productList.filter(item => this.selectable0(item)))
+ }
}, 200)
})
},
@@ -1885,7 +1992,7 @@
}
},
selectable0(row,index) {
- if (this.active > 1||row.repetitionTag) {
+ if (!this.canSelectProduct||row.repetitionTag) {
return false
} else {
return true
@@ -1956,17 +2063,57 @@
return item
})
}
- this.productList.forEach(item => {
- if (item.id == row.id) {
- item.state = row.state;
- }
- })
this.changeProductList0()
this.currentMethod.insProduct = this.productList0
+ this.inspectionScope = e.length > 0 ? 'all' : 'specified'
this.getProNum()
this.$nextTick(() => {
this.$refs.productTable.doLayout()
})
+ },
+ changeInspectionScope(scope) {
+ if (scope !== 'all' || this.productList.length === 0) return
+ this.$refs.productTable.clearSelection()
+ this.productList.forEach(item => {
+ if (this.selectable0(item)) this.$refs.productTable.toggleRowSelection(item, true)
+ })
+ this.handleAll(this.productList.filter(item => this.selectable0(item)))
+ },
+ inspectionProductKey(product) {
+ return [
+ product.structureItemParameterId,
+ product.inspectionItemClass,
+ product.inspectionItem,
+ product.inspectionItemSubclass
+ ].join('|')
+ },
+ loadSelectableProducts(sample) {
+ const selectedProducts = sample.insProduct || []
+ if (!sample.standardMethodListId) return Promise.resolve(sample)
+ const product = selectedProducts[0] || {}
+ const factory = [
+ product.factory || this.addObj.factory,
+ product.laboratory || this.addObj.laboratory,
+ product.sampleType || this.addObj.sampleType,
+ product.sample || sample.sample,
+ product.model || sample.model
+ ].join(' - ')
+ return selectStandardProductList({
+ model: sample.model,
+ modelNum: sample.modelNum,
+ standardMethodListId: sample.standardMethodListId,
+ factory,
+ cores: sample.cores,
+ conductorMaterial: sample.conductorMaterial,
+ conductorType: sample.conductorType
+ }).then(res => {
+ const selectedKeys = new Set(selectedProducts.map(item => this.inspectionProductKey(item)))
+ const availableProducts = (res.data || [])
+ .filter(item => !selectedKeys.has(this.inspectionProductKey(item)))
+ .map((item, index) => ({...item, id: `new-${sample.id}-${index}`, state: 0, isNew: true}))
+ sample.insProduct = selectedProducts.concat(availableProducts)
+ return sample
+ }).catch(() => sample)
},
submitTell() {
if (!this.tell) {
@@ -2151,8 +2298,8 @@
})
},
changeUser(){
- if(this.sonLaboratoryList.length>0){
- this.distributeData.sonLaboratory = this.sonLaboratoryList[0].value
+ if(this.newJuLaboratoryList.length>0){
+ this.distributeData.sonLaboratory = this.newJuLaboratoryList[0].value
}
},
addProductList(productList,row,index){
--
Gitblit v1.9.3