作者 张晓杰

Merge branch 'dev' of http://39.105.222.208:1024/leihd/factory-web into dev

@@ -112,6 +112,14 @@ export function yanshouList(url,parameter){ @@ -112,6 +112,14 @@ export function yanshouList(url,parameter){
112 params:parameter 112 params:parameter
113 }) 113 })
114 } 114 }
  115 +//修改验收
  116 +export function updateYan(url,parameter){
  117 + return axios({
  118 + url:url,
  119 + method:'put',
  120 + data:parameter
  121 + })
  122 +}
115 //工序查询 123 //工序查询
116 export function querygx(url,parameter){ 124 export function querygx(url,parameter){
117 return axios({ 125 return axios({
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 data () { 24 data () {
25 return { 25 return {
26 title:"操作", 26 title:"操作",
27 - width:670, 27 + width:800,
28 visible: false, 28 visible: false,
29 disableSubmit: false 29 disableSubmit: false
30 } 30 }
@@ -20,10 +20,11 @@ @@ -20,10 +20,11 @@
20 </template> 20 </template>
21 21
22 <script> 22 <script>
23 -import { httpAction, getAction,yanshouList } from '@/api/manage' 23 +import { httpAction, getAction, yanshouList } from '@/api/manage'
24 import { validateDuplicateValue } from '@/utils/util' 24 import { validateDuplicateValue } from '@/utils/util'
25 import { JeecgListMixin } from '@/mixins/JeecgListMixin' 25 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
26 -import { yanshou } from '../../../api/manage' 26 +import { updateYan, yanshou } from '../../../api/manage'
  27 +import { mapGetters } from 'vuex'
27 export default { 28 export default {
28 name: 'TblProductionYansForm', 29 name: 'TblProductionYansForm',
29 mixins: [JeecgListMixin], 30 mixins: [JeecgListMixin],
@@ -44,11 +45,13 @@ export default { @@ -44,11 +45,13 @@ export default {
44 { 45 {
45 title: '工序', 46 title: '工序',
46 align: 'center', 47 align: 'center',
  48 + width: 220,
47 dataIndex: 'workingProcedure', 49 dataIndex: 'workingProcedure',
48 }, 50 },
49 { 51 {
50 title: '承接人', 52 title: '承接人',
51 align: 'center', 53 align: 'center',
  54 + width: 150,
52 dataIndex: 'undertaker', 55 dataIndex: 'undertaker',
53 }, 56 },
54 { 57 {
@@ -59,12 +62,31 @@ export default { @@ -59,12 +62,31 @@ export default {
59 { 62 {
60 title: '验收结果', 63 title: '验收结果',
61 align: 'center', 64 align: 'center',
  65 + width: 100,
  66 + modified: false,
62 dataIndex: 'yanResult', 67 dataIndex: 'yanResult',
  68 + customRender: (text, record, index) => {
  69 + return (
  70 + <a-select
  71 + v-model={record.yanResult}
  72 + style="width: 100%;"
  73 + onChange={() => this.handleYanResultChange(record)}
  74 + >
  75 + <a-select-option value="合格入库">合格入库</a-select-option>
  76 + <a-select-option value="不合格">不合格</a-select-option>
  77 + </a-select>
  78 + )
  79 + },
63 }, 80 },
64 { 81 {
65 title: '备注', 82 title: '备注',
66 align: 'center', 83 align: 'center',
  84 + width: 150,
  85 + modified2: false,
67 dataIndex: 'notes', 86 dataIndex: 'notes',
  87 + customRender: (text, record, index) => {
  88 + return <a-input v-model={record.notes} style="text-align: center" v-on:input={() => this.handleInputChange(record)} />
  89 + },
68 }, 90 },
69 ], 91 ],
70 labelCol: { 92 labelCol: {
@@ -84,9 +106,10 @@ export default { @@ -84,9 +106,10 @@ export default {
84 zongPrice: [{ required: true, message: '请输入总工资算法!' }], 106 zongPrice: [{ required: true, message: '请输入总工资算法!' }],
85 }, 107 },
86 url: { 108 url: {
87 - list:'/production/tblProductionGongxu/list', 109 + list: '/production/tblProductionGongxu/list',
88 edit: '/production/tblProductionGongxu/edit', 110 edit: '/production/tblProductionGongxu/edit',
89 - queryByNumber:'/production/tblProductionGongxu/queryByNumber' 111 + queryByNumber: '/production/tblProductionGongxu/queryByNumber',
  112 + updateYan: '/production/tblProductionGongxu/updateYan',
90 }, 113 },
91 } 114 }
92 }, 115 },
@@ -100,13 +123,55 @@ export default { @@ -100,13 +123,55 @@ export default {
100 this.modelDefault = JSON.parse(JSON.stringify(this.model)) 123 this.modelDefault = JSON.parse(JSON.stringify(this.model))
101 }, 124 },
102 methods: { 125 methods: {
103 - yanshouList(record){ 126 + handleInputChange(record){
  127 + // 找到当前更改行的索引
  128 + const index = this.res.findIndex((item) => item.id === record.id)
  129 + console.log("index:",index)
  130 + // 如果找到了该行
  131 + if (index !== -1) {
  132 + this.res[index].modified2 = true
  133 + }
  134 + console.log("modified2:",this.res[index].modified2)
  135 + },
  136 + handleYanResultChange(record) {
  137 + console.log('当前更改的行的ID:', record.id)
  138 + console.log('当前选中的值:', record.yanResult)
  139 +
  140 + // 找到当前更改行的索引
  141 + const index = this.res.findIndex((item) => item.id === record.id)
  142 +
  143 + // 如果找到了该行
  144 + if (index !== -1) {
  145 + console.log('页面加载时显示的值:', this.res[index].originalYanResult)
  146 +
  147 + // 比较当前选中的值和页面加载时显示的值
  148 + if (record.yanResult !== this.res[index].originalYanResult) {
  149 + // 如果不相同,则将 modified 属性设置为 true
  150 + this.res[index].modified = true
  151 + } else {
  152 + // 如果相同,则将 modified 属性设置为 false
  153 + this.res[index].modified = false
  154 + }
  155 + }
  156 + },
  157 + ...mapGetters(['nickname', 'avatar', 'userInfo']),
  158 + yanshouList(record) {
104 console.log(record.orderId) 159 console.log(record.orderId)
105 - yanshouList(this.url.queryByNumber,{orderNumber:record.orderId}).then((res) =>{  
106 - if(res){  
107 - this.res=res.result  
108 - }  
109 - }) 160 + yanshouList(this.url.queryByNumber, { orderId: record.orderId }).then((ress) => {
  161 + if (ress) {
  162 + this.res = ress.result.map((item) => ({
  163 + id: item.id,
  164 + workingProcedure: item.workingProcedure,
  165 + undertaker: item.undertaker,
  166 + workHours: item.workHours,
  167 + yanResult: item.yanResult,
  168 + notes: item.notes,
  169 + yanRen: this.userInfo().realname,
  170 + yanTime: new Date(),
  171 + originalYanResult: item.yanResult, // 添加一个 originalYanResult 属性保存页面加载时的值
  172 + }))
  173 + }
  174 + })
110 }, 175 },
111 edit(record) { 176 edit(record) {
112 this.model = Object.assign({}, record) 177 this.model = Object.assign({}, record)
@@ -118,10 +183,26 @@ export default { @@ -118,10 +183,26 @@ export default {
118 this.$refs.form.validate((valid) => { 183 this.$refs.form.validate((valid) => {
119 if (valid) { 184 if (valid) {
120 that.confirmLoading = true 185 that.confirmLoading = true
121 - let httpurl = ''  
122 - let method = ''  
123 -  
124 - httpAction(this.url, this.model, method) 186 +
  187 + // 对记录进行分组,根据不同字段的修改情况进行更新
  188 + const recordsToUpdate = this.res.reduce((acc, record) => {
  189 + console.log("是否修改2:",record.modified2)
  190 + console.log("是否修改:",record.modified)
  191 + // 判断是否有字段被修改
  192 + if (record.modified) {
  193 + // 若 yanResult 字段被修改,则整条记录更新
  194 + if (record.yanResult !== record.originalYanResult) {
  195 + acc.push(record)
  196 + }
  197 + }else if(record.modified2){
  198 + // 若只有 notes 字段被修改,则只更新 notes 字段
  199 + const updatedRecord = Object.assign({}, record, { notes: record.notes })
  200 + console.log("备注:",updatedRecord)
  201 + acc.push(updatedRecord)
  202 + }
  203 + return acc
  204 + }, [])
  205 + updateYan(this.url.updateYan, recordsToUpdate)
125 .then((res) => { 206 .then((res) => {
126 if (res.success) { 207 if (res.success) {
127 that.$message.success(res.message) 208 that.$message.success(res.message)