Commit 0e586f48 authored by 盖献康's avatar 盖献康

feat: 发起新任务 -> 小接口都对完,只差最后一步

parent 3cb866af
import request from '@/utils/request' import request from '@/utils/request'
import { parseStrEmpty } from '@/utils/ruoyi' import { parseStrEmpty } from '@/utils/ruoyi'
// 通过角色名查询用户
export function getUserByRole(data) {
return request({
url: '/system/user/getUserByRole',
method: 'post',
data: data
})
}
// 查询用户列表 // 查询用户列表
export function listUser(query) { export function listUser(query) {
return request({ return request({
......
...@@ -210,20 +210,20 @@ ...@@ -210,20 +210,20 @@
border border
:data="tableData" :data="tableData"
> >
<el-table-column label="姓名" align="left" prop="name"> <el-table-column label="姓名" align="left" prop="nickName">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<span v-if="row.name !== ''">{{ row.name }}</span> <span v-if="row.userId !== ''">{{ row.nickName }}</span>
<el-select <el-select
v-else v-else
v-model="name" v-model="userId"
placeholder="请选择" placeholder="请选择"
@change="handleNameChange" @change="handleNameChange"
> >
<el-option <el-option
v-for="(item, index) in userList" v-for="(item, index) in userList"
:key="index" :key="index"
:label="item.name" :label="item.nickName"
:value="item.name" :value="item.userId"
:disabled="item.disabled" :disabled="item.disabled"
> >
</el-option> </el-option>
...@@ -232,19 +232,21 @@ ...@@ -232,19 +232,21 @@
</el-table-column> </el-table-column>
<el-table-column label="组内角色" align="left" prop="role"> <el-table-column label="组内角色" align="left" prop="role">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<span v-if="row.name === ''">-</span> <span v-if="row.userId === ''">-</span>
<span v-else>{{ row.role }}</span> <!-- <span v-else>{{ row.dept.deptName }}</span>-->
<span v-else-if="row.isLeader === 1"> 组长 </span>
<span v-else-if="row.isLeader === 0"> 组员 </span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="所属部门" align="left" prop="dept"> <el-table-column label="所属部门" align="left" prop="dept">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<span v-if="row.name === ''">-</span> <span v-if="row.userId === ''">-</span>
<span v-else>{{ row.dept }}</span> <span v-else>{{ row.dept.deptName }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="orderIndex" label="排序"> <el-table-column prop="orderIndex" label="排序">
<template slot-scope="scope"> <template slot-scope="scope">
<div v-if="scope.row.role !== '组长'" class="sortable-handle"> <div v-if="scope.row.isLeader !== 2" class="sortable-handle">
{{ '拖动排序' }} {{ '拖动排序' }}
</div> </div>
</template> </template>
...@@ -256,7 +258,7 @@ ...@@ -256,7 +258,7 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-show="scope.row.name !== ''" v-show="scope.row.userId !== ''"
size="mini" size="mini"
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-edit"
...@@ -266,7 +268,7 @@ ...@@ -266,7 +268,7 @@
修改 修改
</el-button> </el-button>
<el-button <el-button
v-show="scope.row.name !== ''" v-show="scope.row.userId !== ''"
size="mini" size="mini"
type="danger" type="danger"
icon="el-icon-delete" icon="el-icon-delete"
...@@ -276,7 +278,7 @@ ...@@ -276,7 +278,7 @@
删除 删除
</el-button> </el-button>
<el-button <el-button
v-show="scope.row.name === ''" v-show="scope.row.userId === ''"
size="mini" size="mini"
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-edit"
...@@ -286,7 +288,7 @@ ...@@ -286,7 +288,7 @@
保存 保存
</el-button> </el-button>
<el-button <el-button
v-show="scope.row.name === ''" v-show="scope.row.userId === ''"
size="mini" size="mini"
type="danger" type="danger"
icon="el-icon-delete" icon="el-icon-delete"
...@@ -473,6 +475,7 @@ import { manufacturerData } from '../../../api/task/new' ...@@ -473,6 +475,7 @@ import { manufacturerData } from '../../../api/task/new'
import CarInfo from './components/CarInfo' import CarInfo from './components/CarInfo'
import PartInfo from './components/PartInfo' import PartInfo from './components/PartInfo'
import { selectSamplePage } from '@/api/system/sample' import { selectSamplePage } from '@/api/system/sample'
import { getUserByRole } from '@/api/system/user'
export default { export default {
dicts: [ dicts: [
'sys_task_status', 'sys_task_status',
...@@ -486,6 +489,42 @@ export default { ...@@ -486,6 +489,42 @@ export default {
}, },
data() { data() {
return { return {
// 最终提交
taskCreateRequest: {
standardId: 1, // 检验依据
taskNo: '', // 任务编号
taskName: '', // 任务名称
confidentialityLevel: '', // 保密等级
productName: '', // 产品名称
productModel: '', // 车辆型号
entrustedUnit: '', // 委托单位
entrustedUnitAddress: '', // 委托单位地址
entrustedUnitPhone: '', // 委托单位电话
entrustedUnitCode: '', // 委托单位邮政编码
// 小组成员
auditors: [
{
userId: '', // 审核人id
name: '', // 审核人姓名
isLeader: '', // 是否是组长
deptName: '' // 部门名称
}
],
// 整车样品信息
sample: [
{
sampleId: '', // 样品id
flag: 0
}
],
// 零部件样品信息
partSample: [
{
sampleId: '', // 样品id
flag: 1
}
]
},
carInfoArr: [ carInfoArr: [
{ {
identificationCode: '', // 车辆识别码(VIN) identificationCode: '', // 车辆识别码(VIN)
...@@ -504,7 +543,7 @@ export default { ...@@ -504,7 +543,7 @@ export default {
// 零件样品信息结合 // 零件样品信息结合
partSampleInformationList: [], partSampleInformationList: [],
websock: null, websock: null,
name: '', userId: '',
formType: '1', formType: '1',
showTestScenario: false, showTestScenario: false,
// 新增/保存 - 对象 // 新增/保存 - 对象
...@@ -523,9 +562,9 @@ export default { ...@@ -523,9 +562,9 @@ export default {
}, },
loading: false, loading: false,
tableData: [ tableData: [
{ name: '老二', role: '组员', dept: '第一部门', disabled: true }, // { nickName: '老二', role: '组员', dept: '第一部门', disabled: true },
{ name: '老三', role: '组员', dept: '第一部门', disabled: true }, // { nickName: '老三', role: '组员', dept: '第一部门', disabled: true },
{ name: '老大', role: '组长', dept: '第一部门', disabled: true } // { nickName: '老大', role: '组长', dept: '第一部门', disabled: true }
], ],
inspectionItemList: [ inspectionItemList: [
{ value: 0, label: '汽车信息安全管理体系要求', check: false }, { value: 0, label: '汽车信息安全管理体系要求', check: false },
...@@ -642,11 +681,11 @@ export default { ...@@ -642,11 +681,11 @@ export default {
] ]
}, },
userList: [ userList: [
{ name: '老大', role: '组长', dept: '第一部门', disabled: true }, // { nickName: '老大', role: '组长', dept: '第一部门', disabled: true },
{ name: '老二', role: '组员', dept: '第一部门', disabled: true }, // { nickName: '老二', role: '组员', dept: '第一部门', disabled: true },
{ name: '老三', role: '组员', dept: '第一部门', disabled: true }, // { nickName: '老三', role: '组员', dept: '第一部门', disabled: true },
{ name: '老四', role: '组员', dept: '第一部门', disabled: false }, // { nickName: '老四', role: '组员', dept: '第一部门', disabled: false },
{ name: '老五', role: '组员', dept: '第一部门', disabled: false } // { nickName: '老五', role: '组员', dept: '第一部门', disabled: false }
], ],
imageUrl: '', imageUrl: '',
productionEnterpriseList: [ productionEnterpriseList: [
...@@ -716,6 +755,7 @@ export default { ...@@ -716,6 +755,7 @@ export default {
// this.initWebSocket() // this.initWebSocket()
// 查询样品信息(整车、零件) // 查询样品信息(整车、零件)
this.getSampleInformation() this.getSampleInformation()
this.getUserByRole()
this.getManufacturer() this.getManufacturer()
this.$nextTick(() => { this.$nextTick(() => {
this.leaderTop() this.leaderTop()
...@@ -726,6 +766,13 @@ export default { ...@@ -726,6 +766,13 @@ export default {
this.websock.close() // 离开路由之后断开websocket连接 this.websock.close() // 离开路由之后断开websocket连接
}, },
methods: { methods: {
getUserByRole() {
getUserByRole({ roleName: '检验员' }).then(response => {
this.userList = response.data.map(obj => {
return { ...obj, disabled: false }
})
})
},
handleCarsChange(cards) { handleCarsChange(cards) {
console.log('CarInfo组件传值', cards) console.log('CarInfo组件传值', cards)
}, },
...@@ -789,12 +836,12 @@ export default { ...@@ -789,12 +836,12 @@ export default {
if (this.tableData.length !== 0) { if (this.tableData.length !== 0) {
this.tableData.findIndex((item, index) => { this.tableData.findIndex((item, index) => {
// 循环遍历数组是否有组长 // 循环遍历数组是否有组长
if (item.role === '组长') { if (item.isLeader === 1) {
let obj = {} let obj = {}
this.tableData.length && this.tableData.length &&
this.tableData.forEach((item, index) => { this.tableData.forEach((item, index) => {
// 在数组中循环遍历找到组长并置顶 // 在数组中循环遍历找到组长并置顶
if (item.role === '组长') { if (item.isLeader === 1) {
obj = item obj = item
this.tableData.splice(index, 1) this.tableData.splice(index, 1)
return return
...@@ -829,6 +876,14 @@ export default { ...@@ -829,6 +876,14 @@ export default {
_this.tableData = [] _this.tableData = []
_this.$nextTick(() => { _this.$nextTick(() => {
_this.tableData = newArray _this.tableData = newArray
// 把第一行的人员设定为组长
_this.tableData = _this.tableData.map((item, index) => {
if (index === 0) {
return { ...item, isLeader: 1 }
} else {
return { ...item, isLeader: 0 }
}
})
console.log('_this.tableData', _this.tableData) console.log('_this.tableData', _this.tableData)
}) })
} }
...@@ -841,8 +896,8 @@ export default { ...@@ -841,8 +896,8 @@ export default {
handleUpdate(row) { handleUpdate(row) {
console.log('修改', row) console.log('修改', row)
// 取消禁用 // 取消禁用
this.userList.find(item => item.name === row.name).disabled = false this.userList.find(item => item.userId === row.userId).disabled = false
this.tableData.find(item => item.name === row.name).name = '' this.tableData.find(item => item.userId === row.userId).userId = ''
}, },
handleInspectionItem(item) { handleInspectionItem(item) {
// 查看item.value在this.checkTestScenarioList里面存不存在 // 查看item.value在this.checkTestScenarioList里面存不存在
...@@ -885,9 +940,11 @@ export default { ...@@ -885,9 +940,11 @@ export default {
closeOnClickModal: false, closeOnClickModal: false,
confirmButtonClass: 'queryBtn' confirmButtonClass: 'queryBtn'
}).then(() => { }).then(() => {
this.tableData = this.tableData.filter(item => item.name !== row.name) this.tableData = this.tableData.filter(
item => item.userId !== row.userId
)
// 把当前人取消禁用 // 把当前人取消禁用
this.userList.find(item => item.name === row.name).disabled = false this.userList.find(item => item.userId === row.userId).disabled = false
}) })
}, },
/** /**
...@@ -895,21 +952,29 @@ export default { ...@@ -895,21 +952,29 @@ export default {
* @param row * @param row
*/ */
handleSavePeople(row) { handleSavePeople(row) {
const obj = this.userList.find(item => item.name === this.name) const obj = this.userList.find(item => item.userId === this.userId)
const currentData = this.tableData.find(item => item.name === row.name) const currentData = this.tableData.find(
currentData.name = this.name item => item.userId === row.userId
)
currentData.userId = this.userId
currentData.nickName = obj.nickName
currentData.dept = obj.dept currentData.dept = obj.dept
currentData.role = obj.role
// 已被选择的人做禁用 // 已被选择的人做禁用
this.userList.find(item => item.name === this.name).disabled = true this.userList.find(item => item.userId === this.userId).disabled = true
this.name = '' this.userId = ''
this.leaderTop() this.leaderTop()
if (this.tableData.length === 1) {
currentData.isLeader = 1
} else {
currentData.isLeader = 0
}
console.log('现在的对象', this.tableData)
}, },
/** /**
* 取消人员 * 取消人员
*/ */
handleCancelPeople() { handleCancelPeople() {
this.name = '' this.userId = ''
// 去掉一个数组最后一个对象 // 去掉一个数组最后一个对象
this.tableData.pop() this.tableData.pop()
}, },
...@@ -923,18 +988,18 @@ export default { ...@@ -923,18 +988,18 @@ export default {
const lastObj = this.tableData[this.tableData.length - 1] const lastObj = this.tableData[this.tableData.length - 1]
let num = 0 let num = 0
this.tableData.forEach(item => { this.tableData.forEach(item => {
if (item.name === '') { if (item.userId === '') {
num++ num++
} }
}) })
if (lastObj.name === '' || num === 1) { if (lastObj.userId === '' || num === 1) {
this.$message.error('请填写完此成员信息') this.$message.error('请填写完此成员信息')
return return
} else { } else {
this.tableData.push({ name: '' }) this.tableData.push({ userId: '' })
} }
} else { } else {
this.tableData.push({ name: '' }) this.tableData.push({ userId: '' })
} }
}, },
handleNameChange(value) {}, handleNameChange(value) {},
...@@ -958,6 +1023,7 @@ export default { ...@@ -958,6 +1023,7 @@ export default {
console.log('a', this.inspectionItemList) console.log('a', this.inspectionItemList)
this.$refs.form.validate(valid => { this.$refs.form.validate(valid => {
if (valid) { if (valid) {
// 开始窜数据
this.$modal.msgSuccess('发布成功') this.$modal.msgSuccess('发布成功')
this.$router.push({ this.$router.push({
path: '/task/on' path: '/task/on'
......
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