|
@@ -39,57 +39,48 @@
|
|
|
<el-col :span="6">
|
|
|
<el-form-item
|
|
|
label="乐团主管"
|
|
|
- :prop="`group.${groupIndex}.zhuguan`"
|
|
|
+ :prop="`group.${groupIndex}.userId`"
|
|
|
:rules="[{required: true, message: '请选择乐团主管'}]"
|
|
|
>
|
|
|
<el-select
|
|
|
clearable
|
|
|
filterable
|
|
|
- v-model="groupItem.zhuguan"
|
|
|
- placeholder="请选择分部"
|
|
|
+ v-model="groupItem.userId"
|
|
|
+ placeholder="请选择乐团主管"
|
|
|
>
|
|
|
- <el-option v-for="(item,index) in selects.branchs"
|
|
|
+ <el-option v-for="(item,index) in technicians"
|
|
|
:key="index"
|
|
|
- :label="item.name"
|
|
|
- :value="item.id"></el-option>
|
|
|
+ :label="item.realName"
|
|
|
+ :value="item.userId"></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<template v-for="(matterItem, matterIndex) in groupItem.matter">
|
|
|
<el-col :offset="matterIndex === 0 ? 0 : 6" :span="6" :key="groupIndex + '-' + matterIndex">
|
|
|
+ {{groupIndex + '-' + matterIndex}}
|
|
|
<el-form-item
|
|
|
:label="'任务事项' + (matterIndex + 1)"
|
|
|
- :prop="`group.${groupIndex}.matter.${matterIndex}.type`"
|
|
|
+ :prop="`group.${groupIndex}.matter.${matterIndex}.item`"
|
|
|
>
|
|
|
<el-select
|
|
|
clearable
|
|
|
filterable
|
|
|
- v-model="matterItem.type"
|
|
|
+ v-model="matterItem.item"
|
|
|
placeholder="请选择任务事项"
|
|
|
>
|
|
|
- <el-option v-for="(item,index) in selects.branchs"
|
|
|
+ <el-option v-for="(item,index) in matterTypesOptions"
|
|
|
:key="index"
|
|
|
- :label="item.name"
|
|
|
- :value="item.id"></el-option>
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6" :key="groupIndex + '-' + matterIndex">
|
|
|
<el-form-item
|
|
|
:label="'任务次数' + (matterIndex + 1)"
|
|
|
- :prop="`group.${groupIndex}.matter.${matterIndex}.num`"
|
|
|
+ :prop="`group.${groupIndex}.matter.${matterIndex}.times`"
|
|
|
>
|
|
|
- <el-select
|
|
|
- clearable
|
|
|
- filterable
|
|
|
- v-model="matterItem.num"
|
|
|
- placeholder="请输入次数"
|
|
|
- >
|
|
|
- <el-option v-for="(item,index) in selects.branchs"
|
|
|
- :key="index"
|
|
|
- :label="item.name"
|
|
|
- :value="item.id"></el-option>
|
|
|
- </el-select>
|
|
|
+ <el-input clearable v-model="matterItem.times" placeholder="请输入次数" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6" :key="groupIndex + '-' + matterIndex">
|
|
@@ -113,7 +104,7 @@
|
|
|
></el-button>
|
|
|
</el-tooltip>
|
|
|
</span>
|
|
|
- <el-tooltip content="删除乐团主管" placement="top" :open-delay=".5">
|
|
|
+ <el-tooltip v-if="isCreate" content="删除乐团主管" placement="top" :open-delay=".5">
|
|
|
<el-button
|
|
|
icon="el-icon-delete"
|
|
|
circle
|
|
@@ -128,7 +119,7 @@
|
|
|
</el-col>
|
|
|
</template>
|
|
|
</el-row>
|
|
|
- <el-button @click="createGroup" plain block style="width: 100%">添加乐团主管</el-button>
|
|
|
+ <el-button v-if="isCreate" @click="createGroup" plain block style="width: 100%">添加乐团主管</el-button>
|
|
|
</el-form>
|
|
|
<div slot="footer" style="text-align: right;margin-top: 20px;">
|
|
|
<el-button>取消</el-button>
|
|
@@ -137,26 +128,72 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+import { findTechnician } from '@/api/repairManager'
|
|
|
+import { matterTypes } from '@/views/main/constant'
|
|
|
+import { objectToOptions } from '@/utils'
|
|
|
+import { createRandom } from '@/helpers/uuidv4'
|
|
|
+import { inspectionAdd, inspectionGetInfo, inspectionUpdate } from '@/views/main/api'
|
|
|
const emptyMatter = {
|
|
|
- name: '',
|
|
|
- num: ''
|
|
|
+ item: '',
|
|
|
+ times: ''
|
|
|
}
|
|
|
export default {
|
|
|
+ props: ['id'],
|
|
|
data() {
|
|
|
return {
|
|
|
form: {
|
|
|
organId: '',
|
|
|
group: [{
|
|
|
- person: '',
|
|
|
+ _uuid: createRandom(),
|
|
|
+ userId: '',
|
|
|
matter: [{...emptyMatter}]
|
|
|
}]
|
|
|
+ },
|
|
|
+ technicians: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ matterTypesOptions() {
|
|
|
+ return objectToOptions(matterTypes)
|
|
|
+ },
|
|
|
+ isCreate() {
|
|
|
+ return !this.id
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ async 'form.organId'() {
|
|
|
+ if (this.form.organId) {
|
|
|
+ try {
|
|
|
+ const res = await findTechnician({
|
|
|
+ organId: this.form.organId
|
|
|
+ })
|
|
|
+ this.technicians = res.data
|
|
|
+ this.$set(this.form, 'group', group.map(item => ({...item, userId: ''})))
|
|
|
+ } catch (error) {}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ async mounted() {
|
|
|
+ try {
|
|
|
+ const res = await inspectionGetInfo({
|
|
|
+ id: this.id
|
|
|
+ })
|
|
|
+ this.form = {
|
|
|
+ ...this.form,
|
|
|
+ organId: res.data.organId,
|
|
|
+ month: res.data.month,
|
|
|
+ group: [{
|
|
|
+ _uuid: createRandom(),
|
|
|
+ userId: res.data.userId,
|
|
|
+ matter: res.data.inspectionItems.map(item => ({item: item.item, times: item.times}))
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ } catch (error) {}
|
|
|
+ },
|
|
|
methods: {
|
|
|
createGroup() {
|
|
|
this.form.group.push({
|
|
|
- person: '',
|
|
|
+ userId: '',
|
|
|
matter: [{...emptyMatter}]
|
|
|
})
|
|
|
},
|
|
@@ -178,7 +215,26 @@ export default {
|
|
|
try {
|
|
|
this.$refs.form.validate(async valid => {
|
|
|
if (valid) {
|
|
|
- console.log(this.form)
|
|
|
+ const data = this.form.group.map(item => ({
|
|
|
+ organId: this.form.organId,
|
|
|
+ month: this.form.month,
|
|
|
+ userId: item.userId,
|
|
|
+ inspectionItems: item.matter.map(m => ({
|
|
|
+ ...m,
|
|
|
+ organId: this.form.organId,
|
|
|
+ month: this.form.month,
|
|
|
+ }))
|
|
|
+ }))
|
|
|
+ if (this.isCreate) {
|
|
|
+ await inspectionAdd(data)
|
|
|
+ this.$message.success('创建成功')
|
|
|
+ } else {
|
|
|
+ await inspectionUpdate({
|
|
|
+ ...data[0],
|
|
|
+ id: this.id,
|
|
|
+ })
|
|
|
+ this.$message.success('修改成功')
|
|
|
+ }
|
|
|
this.$emit('close')
|
|
|
this.$emit('submited')
|
|
|
}
|