diff --git a/src/views/allot/components/chengya_list.vue b/src/views/allot/components/chengya_list.vue index 54b0cd4..8409d42 100644 --- a/src/views/allot/components/chengya_list.vue +++ b/src/views/allot/components/chengya_list.vue @@ -1,7 +1,7 @@ - + - + - - - - - + + + + + @@ -117,55 +253,189 @@ @size-change="handleSizeChange" @current-change="handleCurrentChange" /> - + - - + + - - + + - - + + 执行分配 - - - - + + + + - + - + - - - - - - - - + + + + + + + + - + @@ -247,7 +517,7 @@ export default { url: '/renwu/list', method: 'get', params: this.listQuery - }).then(data => { + }).then((data) => { this.list = data.list this.total = data.total this.showLoading = false @@ -261,7 +531,7 @@ export default { sbzl: undefined, level: '1' } - }).then(data => { + }).then((data) => { this.sbzlList = data }) }, @@ -282,127 +552,184 @@ export default { }, getIndex($index) { // 表格序号 - return (this.listQuery.pageNum - 1) * this.listQuery.pageSize + $index + 1 + return ( + (this.listQuery.pageNum - 1) * this.listQuery.pageSize + $index + 1 + ) }, // 批量分配 renwuFp() { this.allotList = [] if (this.multipleSelection.length === 0) { - this.$message({ message: '请在列表选择要操作的数据。', type: 'warning' }) + this.$message({ + message: '请在列表选择要操作的数据。', + type: 'warning' + }) return false - } - this.bjdIds.length = 0 - this.bjdIds = this.$refs.list.selection.map(rw => rw.bjdId) - this.apibjd({ - url: '/renwu/getAllotBaseList', - method: 'post', - data: { - bjdIds: this.bjdIds - } - }).then(data => { - this.allotList = data - this.allotSbzl = this.allotList[0].shebeizhongleidaima - this.renwudan = { - xiadariqi: this.formatter.dateFormat('YYYY-MM-dd') - } - if (this.multipleSelection[0].shebeileixing !== undefined && this.multipleSelection[0].shebeileixing !== null) { - this.title = '任务分配(' + this.multipleSelection[0].shebeileixing + ')' + } else { + if (this.multipleSelection.length > 1 && !this.arrFn(this.multipleSelection)) { + return this.$message('所选报检单相同使用单位和相同施工单位才能批量分配') } - this.dialogVisible = true - this.$nextTick(() => { - this.$refs.allotList.toggleAllSelection() - this.selection = data.list + this.bjdIds.length = 0 + this.bjdIds = this.$refs.list.selection.map((rw) => rw.bjdId) + this.apibjd({ + url: '/renwu/getAllotBaseList', + method: 'post', + data: { + bjdIds: this.bjdIds + } + }).then((data) => { + this.allotList = data + this.allotSbzl = this.allotList[0].shebeizhongleidaima + this.renwudan = { + shiyongdanwei: this.multipleSelection[0].shiyongdanwei, + shiyongdanweiLianxiren: this.multipleSelection[0].shiyongdanweiLianxiren, + shiyongdanweiDianhua: this.multipleSelection[0].shiyongdanweiDianhua, + shiyongdanweiDizhi: this.multipleSelection[0].shiyongdanweiDizhi, + shigongdanwei: this.multipleSelection[0].shigongdanwei, + shigongdanweiLianxiren: this.multipleSelection[0].shigongdanweiLianxiren, + shigongdanweiDianhua: this.multipleSelection[0].shigongdanweiDianhua, + xiadariqi: this.formatter.dateFormat('YYYY-MM-dd') + } + if ( + this.multipleSelection[0].shebeileixing !== undefined && + this.multipleSelection[0].shebeileixing !== null + ) { + this.title = + '任务分配(' + this.multipleSelection[0].shebeileixing + ')' + } + this.dialogVisible = true + this.$nextTick(() => { + this.$refs.allotList.toggleAllSelection() + this.selection = data.list + }) }) - }) + } }, // 任务异常退回 returnToBjd() { if (this.multipleSelection.length === 0) { - this.$message({ message: '请在列表选择要退回的数据。', type: 'warning' }) + this.$message({ + message: '请在列表选择要退回的数据。', + type: 'warning' + }) return false } this.bjdIds.length = 0 - this.bjdIds = this.$refs.list.selection.map(rw => rw.bjdId) + this.bjdIds = this.$refs.list.selection.map((rw) => rw.bjdId) // 查询任务的分配状态 for (let i = 0; i < this.multipleSelection.length; i++) { - if (this.multipleSelection[i].allotNum !== this.multipleSelection[i].totalNum) { - this.$message({ message: '有任务已经分配,请重新选择。', type: 'warning' }) + if ( + this.multipleSelection[i].allotNum !== + this.multipleSelection[i].totalNum + ) { + this.$message({ + message: '有任务已经分配,请重新选择。', + type: 'warning' + }) return false } else { this.$prompt('请输入退回原因', '提示', { inputType: 'textarea', confirmButtonText: '确定', cancelButtonText: '取消' - }).then(({ value }) => { - this.apibjd({ - url: '/bjd/returnToBjd', - method: 'get', - params: { - bjdIds: this.bjdIds, - reason: value - } - }).then(data => { - this.getList() - this.$message({ message: '任务异常退回成功', type: 'success' }) + }) + .then(({ value }) => { + this.apibjd({ + url: '/bjd/returnToBjd', + method: 'get', + params: { + bjdIds: this.bjdIds, + reason: value + } + }).then((data) => { + this.getList() + this.$message({ message: '任务异常退回成功', type: 'success' }) + }) }) - }).catch(() => { - this.$message({ - type: 'info', - message: '取消输入' + .catch(() => { + this.$message({ + type: 'info', + message: '取消输入' + }) }) - }) } } }, // 作废数据 renwuZf() { if (this.multipleSelection.length === 0) { - this.$message({ message: '请在列表选择要作废的数据。', type: 'warning' }) + this.$message({ + message: '请在列表选择要作废的数据。', + type: 'warning' + }) return false } if (this.multipleSelection.length > 1) { - this.$message({ message: '请选择单条报检单进行作废。', type: 'warning' }) + this.$message({ + message: '请选择单条报检单进行作废。', + type: 'warning' + }) return false } this.$prompt('请输入作废原因!', '提示', { inputType: 'textarea', confirmButtonText: '确定', cancelButtonText: '取消' - }).then(({ value }) => { - if (value === null) { - this.$message({ message: '请填写作废原因!', type: 'warning' }) - return false - } - this.apibjd({ - url: '/bjd/zfDbRenwuByBjdId', - method: 'get', - params: { - bjdIds: this.$refs.list.selection[0].bjdId, - reason: value - } - }).then(data => { - this.getList() - if (data.count > 0) { - this.$alert(data.count + '条任务作废成功!', '确认信息', { - confirmButtonText: '确定' - }) - } else { - this.$message({ message: '任务作废失败!', type: 'warning' }) + }) + .then(({ value }) => { + if (value === null) { + this.$message({ message: '请填写作废原因!', type: 'warning' }) + return false } + this.apibjd({ + url: '/bjd/zfDbRenwuByBjdId', + method: 'get', + params: { + bjdIds: this.$refs.list.selection[0].bjdId, + reason: value + } + }).then((data) => { + this.getList() + if (data.count > 0) { + this.$alert(data.count + '条任务作废成功!', '确认信息', { + confirmButtonText: '确定' + }) + } else { + this.$message({ message: '任务作废失败!', type: 'warning' }) + } + }) }) - }).catch(() => { - this.$message({ - type: 'info', - message: '取消作废' + .catch(() => { + this.$message({ + type: 'info', + message: '取消作废' + }) }) - }) }, viewBjd(bjd) { const type = '/finish' if (bjd.jianyanleibie === 'DJ') { - this.$router.push({ path: '/bjd/bjd-dj-input/' + bjd.bjdId + '/' + bjd.shebeizhongleidaima + '/' + bjd.shebeizhongleidaima + type }) + this.$router.push({ + path: + '/bjd/bjd-dj-input/' + + bjd.bjdId + + '/' + + bjd.shebeizhongleidaima + + '/' + + bjd.shebeizhongleidaima + + type + }) } else { - this.$router.push({ path: '/bjd/bjd-jj-input/' + bjd.bjdId + '/' + bjd.shebeizhongleidaima + '/' + bjd.shebeizhongleidaima + type }) + this.$router.push({ + path: + '/bjd/bjd-jj-input/' + + bjd.bjdId + + '/' + + bjd.shebeizhongleidaima + + '/' + + bjd.shebeizhongleidaima + + type + }) } }, viewBjdRenwu(bjdid) { @@ -417,7 +744,7 @@ export default { data: { bjdIds: this.bjdIds } - }).then(data => { + }).then((data) => { this.allotList = data.list this.allotSbzl = this.allotList[0].shebeizhongleidaima this.dialogVisible = true @@ -450,24 +777,25 @@ export default { this.api({ url: '/department/all', method: 'get' - }).then(data => { + }).then((data) => { this.depts = data }) }, - getArea() { // 查询区划 + getArea() { + // 查询区划 this.api({ url: '/area/getShiArea', method: 'get', params: { shidaima: '370100' } - }).then(data => { + }).then((data) => { this.areas = data }) }, selectDepartmentUser(val) { this.renlingren = [] - this.getUserList(val) + this.getTeamList(val) }, getUserList(val) { this.api({ @@ -476,26 +804,34 @@ export default { params: { departmentId: val } - }).then(data => { + }).then((data) => { this.users = data }) }, openZhongjian() { if (this.multipleSelection.length !== 1) { - this.$message({ message: '请在列表选择要进行现场检验的设备,只允许单台操作。', type: 'warning' }) + this.$message({ + message: '请在列表选择要进行现场检验的设备,只允许单台操作。', + type: 'warning' + }) return false } if (this.multipleSelection[0].zhongjianriqi) { - this.bjdZhongjian.xianchangriqi = this.multipleSelection[0].zhongjianriqi + this.bjdZhongjian.xianchangriqi = + this.multipleSelection[0].zhongjianriqi } else { this.bjdZhongjian.xianchangriqi = new Date() } - this.bjdZhongjian.xianchangbeizhu = this.multipleSelection[0].zhongjianBeizhu + this.bjdZhongjian.xianchangbeizhu = + this.multipleSelection[0].zhongjianBeizhu this.dialogXianchangVisible = true }, openBaseZhongjian() { if (this.multipleSelection.length !== 1) { - this.$message({ message: '请在列表选择要操作的数据,只能选择单台设备。', type: 'warning' }) + this.$message({ + message: '请在列表选择要操作的数据,只能选择单台设备。', + type: 'warning' + }) return false } this.apibjd({ @@ -504,14 +840,17 @@ export default { data: { bjdIds: [this.multipleSelection[0].bjdId] } - }).then(data => { + }).then((data) => { this.allotList = data.list this.dialogXcjyVisible = true }) }, clearBaseZhongjian() { if (this.multipleSelection.length !== 1) { - this.$message({ message: '请在列表选择要操作的数据,只能选择单台设备。', type: 'warning' }) + this.$message({ + message: '请在列表选择要操作的数据,只能选择单台设备。', + type: 'warning' + }) return false } this.apibjd({ @@ -520,7 +859,7 @@ export default { params: { bjdId: this.multipleSelection[0].bjdId } - }).then(data => { + }).then((data) => { if (data === '清除成功!') { this.getList() } @@ -533,7 +872,7 @@ export default { params: { renwuId: this.allotList[index].id } - }).then(data => { + }).then((data) => { if (data === '清除成功!') { this.allotList[index].shenqingxianchangriqi = null } @@ -544,12 +883,27 @@ export default { this.departmentId = this.$store.getters.departmentId this.users = this.getUserList(this.departmentId) }, + arrFn(arr) { + const ary = new Array(arr) + const nary = arr + if (arr.length > 1) { + for (let i = 0; i < ary.length; i++) { + if ( + nary[i].shiyongdanwei === nary[i + 1].shiyongdanwei && + nary[i].shigongdanwei === nary[i + 1].shigongdanwei + ) { + return true + } + } + } + }, allotRenwu() { this.btnClick = true if (this.selection.length === 0) { this.$message({ message: '请选择要分配的数据。', type: 'warning' }) return false } + if (this.renlingren.length > 0) { for (let i = 0; i < this.teams.length; i++) { if (this.renwudan.teamId === this.teams[i].id) { @@ -596,7 +950,7 @@ export default { url: '/bjd/updBjdEndState', method: 'post', data: this.bjdZhongjian - }).then(data => { + }).then((data) => { this.$message.success('添加成功。') this.getList() this.dialogXianchangVisible = false @@ -604,44 +958,63 @@ export default { }, tijiaoJianyanBf() { if (this.selection.length === 0) { - this.$message({ message: '请在列表选择要操作的数据。', type: 'warning' }) + this.$message({ + message: '请在列表选择要操作的数据。', + type: 'warning' + }) return false } this.bjdZhongjian.bjdid = this.multipleSelection[0].bjdId - this.bjdZhongjian.renwuIds = this.$refs.allotList.selection.map(rw => { - return rw.id - }).join(',') + this.bjdZhongjian.renwuIds = this.$refs.allotList.selection + .map((rw) => { + return rw.id + }) + .join(',') this.apibjd({ url: '/renwu/updBjdEndState', method: 'post', data: this.bjdZhongjian - }).then(data => { + }).then((data) => { this.$message.success('添加成功。') this.getList() this.dialogXcjyVisible = false }) }, - getTeamList(departmentId) { // 获取对应组 + getTeamList(departmentId) { + // 获取对应组 this.apibjd({ url: '/team/getTeamList', method: 'get', params: { departmentId } - }).then(data => { + }).then((data) => { this.teams = data }) }, selectTeamUser(val) { + console.log(this.teams) + const _this = this for (let i = 0; i < this.teams.length; i++) { if (this.teams[i].id === val) { - this.renlingren = JSON.parse(this.teams[i].renyuans) + this.users = this.teams[i].teamPerson.split(',') break } } + this.users = this.users.map((item) => { + const obj = {} + obj.id = item + obj.name = _this.formatter.getChineseName(null, null, item) + return obj + }) + console.log(this.users) }, setWanchengqixian() { var date = new Date(this.renwudan.yuejianriqi) date.setMonth(date.getMonth() + 1) - this.$set(this.renwudan, 'wanchengqixian', this.formatter.dateFormat('YYYY-MM-dd', date)) + this.$set( + this.renwudan, + 'wanchengqixian', + this.formatter.dateFormat('YYYY-MM-dd', date) + ) }, tableRowZhongjian({ row, rowIndex }) { if (row.zhongjianState === 1) { @@ -671,14 +1044,14 @@ export default { diff --git a/src/views/allot/hasAllot.vue b/src/views/allot/hasAllot.vue index e5620b3..2cc02ff 100644 --- a/src/views/allot/hasAllot.vue +++ b/src/views/allot/hasAllot.vue @@ -1,7 +1,7 @@