Commit d68da5ca authored by 盖献康's avatar 盖献康

feat: 任务编辑(除了样品信息)

parent 1c6bb3c4
......@@ -137,6 +137,15 @@ export function createTask(data) {
})
}
// 任务编辑
export function updateTask(data) {
return request({
url: '/task/edit',
method: 'post',
data
})
}
/// 任务删除
export function removeTask(data) {
return request({
......
......@@ -229,12 +229,7 @@
<el-table-column label="姓名" align="left" prop="nickName">
<template slot-scope="{ row }">
<span v-if="row.userId !== ''">{{ row.nickName }}</span>
<el-select
v-else
v-model="userId"
placeholder="请选择"
@change="handleNameChange"
>
<el-select v-else v-model="userId" placeholder="请选择">
<el-option
v-for="(item, index) in userList"
:key="index"
......@@ -500,7 +495,7 @@ import CarInfo from './components/CarInfo'
import PartInfo from './components/PartInfo'
import { selectSamplePage } from '@/api/system/sample'
import { getUserByRole } from '@/api/system/user'
import { createTask } from '@/api/task/task'
import { createTask, getTaskById, updateTask } from '@/api/task/task'
import { mapGetters } from 'vuex'
import { getDicts } from '@/api/system/dict/data'
export default {
......@@ -584,6 +579,7 @@ export default {
taskName: '', // 任务名称
confidentialityLevel: '', // 保密等级
productName: '', // 产品名称
productModel: '', // 车辆型号
entrustedUnit: '', // 委托单位
entrustedUnitAddress: '', // 委托单位地址
entrustedUnitPhone: '', // 委托单位电话
......@@ -742,7 +738,8 @@ export default {
value: 4,
label: '车企五'
}
]
],
taskId: undefined
}
},
watch: {
......@@ -792,12 +789,10 @@ export default {
},
created() {
// 对字典:inspection_item, 做处理
this.getInspectionItemDict()
this.getUserByRole()
// this.initWebSocket()
// 查询样品信息(整车、零件)
this.getSampleInformation()
this.getUserByRole()
this.getManufacturer()
this.$nextTick(() => {
this.leaderTop()
this.rowDrop()
......@@ -811,6 +806,60 @@ export default {
// this.websock.close() // 离开路由之后断开websocket连接
// },
methods: {
getTaskDetail(taskId) {
getTaskById({ id: taskId }).then(response => {
console.log('response', response)
this.taskDetail = response.data
// 任务信息-(检验依据、检验项目)
this.model.formType = this.taskDetail.standardId
this.taskDetail.taskList = this.taskDetail.taskList.split(',')
this.model.inspectionItemList = this.taskDetail.taskList
this.inspectionItemList.forEach(item => {
if (this.taskDetail.taskList.includes(item.value)) {
item.check = true
}
})
debugger
console.log('检验项目', this.inspectionItemList)
// 把detail转到model里(任务信息)
for (const key in this.taskDetail) {
// eslint-disable-next-line no-prototype-builtins
if (this.model.hasOwnProperty(key)) {
this.model[key] = this.taskDetail[key]
}
}
// 小组信息
this.tableData = this.taskDetail.auditors
console.log('ddd', this.tableData)
this.tableData.forEach(item => {
item.nickName = item.name
item.dept = { deptName: item.deptName }
item.disabled = true
// 为下拉框做准备
this.userList.forEach(user => {
if (user.userId.toString() === item.userId.toString()) {
user.disabled = true
}
})
})
console.log('小组table', this.tableData)
console.log('this.userList', this.userList)
// 整车样品信息
this.carInfoArr = this.taskDetail.completeVehicleSample
this.carInfoArr.forEach(item => {
item.sampleId = item.id
item.flag = 0
})
// 零件样品信息
this.partInfoArr = this.taskDetail.partVehicleSample
this.partInfoArr.forEach(item => {
item.sampleId = item.id
item.flag = 1
})
console.log('零件样品信息', this.partInfoArr)
console.log('model', this.model)
})
},
getInspectionItemDict() {
getDicts('inspection_item').then(response => {
this.inspectionItemList = response.data.map(
......@@ -822,6 +871,13 @@ export default {
})
)
console.log('aaa', this.inspectionItemList)
// 当编辑时
this.taskId = this.$route.query.taskId
if (this.taskId !== undefined) {
this.getTaskDetail(this.taskId)
this.rules.inspectionItemList[0].required = false
this.rules.testScenarioList[0].required = false
}
})
},
getUserByRole() {
......@@ -829,6 +885,8 @@ export default {
this.userList = response.data.map(obj => {
return { ...obj, disabled: false }
})
console.log('this.userList-1', this.userList)
this.getInspectionItemDict()
})
},
handleCarsChange(cards) {
......@@ -912,14 +970,6 @@ export default {
})
}
},
/** 获取所有生产企业 */
getManufacturer() {
manufacturerData({}).then(res => {
if (res === 200) {
console.log('res', res)
}
})
},
/** 行-拖拽 */
rowDrop() {
const tbody = document.querySelector('.el-table__body-wrapper tbody')
......@@ -955,9 +1005,15 @@ export default {
*/
handleUpdate(row) {
console.log('修改', row)
console.log('this.userList', this.userList)
console.log('this.tableData', this.tableData)
// 取消禁用
this.userList.find(item => item.userId === row.userId).disabled = false
this.tableData.find(item => item.userId === row.userId).userId = ''
this.userList.find(
item => item.userId.toString() === row.userId.toString()
).disabled = false
this.tableData.find(
item => item.userId.toString() === row.userId.toString()
).userId = ''
},
handleInspectionItem(item) {
// 查看item.value在this.checkTestScenarioList里面存不存在
......@@ -1062,22 +1118,6 @@ export default {
this.tableData.push({ userId: '' })
}
},
handleNameChange(value) {},
handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw)
},
beforeAvatarUpload(file) {
// const isJPG = file.type === 'image/jpeg'
// const isLt2M = file.size / 1024 / 1024 < 2
//
// if (!isJPG) {
// this.$message.error('上传头像图片只能是 JPG 格式!')
// }
// if (!isLt2M) {
// this.$message.error('上传头像图片大小不能超过 2MB!')
// }
// return isJPG && isLt2M
},
// 保存
handleAdd() {
console.log('a', this.inspectionItemList)
......@@ -1110,14 +1150,26 @@ export default {
this.taskCreateRequest.sample = this.currentVehicleSampleInformation
this.taskCreateRequest.partSample = this.currentPartSampleInformation
console.log('发布...', this.taskCreateRequest)
createTask(this.taskCreateRequest).then(response => {
if (response.code === 200) {
this.$modal.msgSuccess('发布成功')
this.$router.push({
path: '/task/on'
})
}
})
if (this.taskId === undefined) {
createTask(this.taskCreateRequest).then(response => {
if (response.code === 200) {
this.$modal.msgSuccess('发布成功')
this.$router.push({
path: '/task/on'
})
}
})
} else {
this.taskCreateRequest.id = this.taskId
updateTask(this.taskCreateRequest).then(response => {
if (response.code === 200) {
this.$modal.msgSuccess('修改成功')
this.$router.push({
path: '/task/on'
})
}
})
}
}
})
},
......
......@@ -669,8 +669,13 @@ export default {
}
},
/* 跳转到问卷详情*/
goNext(url) {
this.$router.push({ path: url })
goNext(id) {
this.$router.push({
path: '/task/new',
query: {
taskId: id
}
})
},
teakDelete(id) {
this.$modal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment