|
|
@@ -0,0 +1,314 @@
|
|
|
+<template>
|
|
|
+ <el-dialog append-to-body :title="title" :visible.sync="dialogFormVisible" @close="close">
|
|
|
+ <el-form ref="form" label-position="top" label-width="100px" :model="form" :rules="rules">
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <!-- <el-col :span="12">
|
|
|
+ <el-form-item label="工单名称" prop="name">
|
|
|
+ <el-input v-model="form.name" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col> -->
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="支持人员" prop="assignUserName">
|
|
|
+ <el-input v-model="form.assignUserName" readonly suffix-icon="el-icon-search" @focus="handleSelectUser" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="经销商" prop="dealerNames">
|
|
|
+ <el-input
|
|
|
+ v-model="form.dealerNames"
|
|
|
+ readonly
|
|
|
+ suffix-icon="el-icon-search"
|
|
|
+ @focus="handleSelectDistributor('10')" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="代理商" prop="agentNames">
|
|
|
+ <el-input
|
|
|
+ v-model="form.agentNames"
|
|
|
+ readonly
|
|
|
+ suffix-icon="el-icon-search"
|
|
|
+ @focus="handleSelectDistributor('20')" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 钉钉审批流表单-->
|
|
|
+ <DingTalkFromToVue ref="dingTalkFrom" :col-span="12" />
|
|
|
+ <!-- 钉钉审批流表单-->
|
|
|
+ <!-- <el-row :gutter="20">-->
|
|
|
+
|
|
|
+ <!-- </el-row>-->
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="close">取 消</el-button>
|
|
|
+ <el-button v-if="!form.id" :loading="loading" type="primary" @click="save">确 定</el-button>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 选择支持人员弹窗 -->
|
|
|
+ <select-user ref="selectUser" @save="selectUser" />
|
|
|
+ <!-- 选择经销商弹窗 -->
|
|
|
+ <select-distributor ref="selectDistributor" :multiple="true" :query-params="queryParams" @save="saveDistributors" />
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import workApi from '@/api/work/index'
|
|
|
+ import typeApi from '@/api/work/type'
|
|
|
+ import SelectUser from '@/components/select/SelectUser'
|
|
|
+ import DingTalkFromToVue from './DingTalkFromToVue.vue'
|
|
|
+ import { mapGetters } from 'vuex'
|
|
|
+ import SelectDistributor from '@/components/select/SelectDistributor'
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name: 'WorkOrderEdit',
|
|
|
+ components: {
|
|
|
+ SelectUser,
|
|
|
+ DingTalkFromToVue,
|
|
|
+ SelectDistributor,
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ businessInfo: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ queryParams: {
|
|
|
+ distType: '',
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ form: {
|
|
|
+ nboId: undefined,
|
|
|
+ nboName: undefined,
|
|
|
+ nboCode: undefined,
|
|
|
+ custId: undefined,
|
|
|
+ custName: undefined,
|
|
|
+ name: undefined,
|
|
|
+ orderTypeId: undefined,
|
|
|
+ orderTypeName: undefined,
|
|
|
+ assignUserId: undefined,
|
|
|
+ assignUserName: undefined,
|
|
|
+ formData: undefined,
|
|
|
+ dingTalkFormData: undefined,
|
|
|
+ feedback: undefined,
|
|
|
+ // file: undefined,
|
|
|
+ remark: undefined,
|
|
|
+ endTime: undefined,
|
|
|
+ dingtalkForm: undefined,
|
|
|
+ trialTimeStart: undefined,
|
|
|
+ trialTimeEnd: undefined,
|
|
|
+ expectTime: undefined,
|
|
|
+ supportTime: undefined,
|
|
|
+ dealerNames: undefined,
|
|
|
+ agentNames: undefined,
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ name: [{ required: true, message: '不能为空', trigger: ['blur', 'change'] }],
|
|
|
+ orderTypeId: [{ required: true, message: '不能为空', trigger: ['blur', 'change'] }],
|
|
|
+ assignUserName: [{ required: true, message: '不能为空', trigger: ['blur', 'change'] }],
|
|
|
+ },
|
|
|
+ title: '',
|
|
|
+ dialogFormVisible: false,
|
|
|
+ orderTypeList: [],
|
|
|
+ dingtalkForm: undefined,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters({
|
|
|
+ userId: 'user/id',
|
|
|
+ nickName: 'user/nickName',
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ mounted() {},
|
|
|
+ methods: {
|
|
|
+ async getOrderTypeList() {
|
|
|
+ this.orderTypeList.splice(0, this.orderTypeList.length)
|
|
|
+ const { data } = await typeApi.getList()
|
|
|
+ for (let item of data.list) {
|
|
|
+ this.orderTypeList.push(item)
|
|
|
+ }
|
|
|
+ this.changeOrderType()
|
|
|
+ },
|
|
|
+ changeOrderType() {
|
|
|
+ let item = this.orderTypeList.find((item) => {
|
|
|
+ return item.name === '经销商支持'
|
|
|
+ })
|
|
|
+ this.form.orderTypeId = item.id
|
|
|
+ this.form.orderTypeName = item.name
|
|
|
+ this.form.orderTypeCode = item.workflowCode
|
|
|
+ this.dingtalkForm = JSON.parse(item.formColumn)
|
|
|
+ for (let index in this.dingtalkForm.items) {
|
|
|
+ // if (this.dingtalkForm.items[index].props.label === '项目编码') {
|
|
|
+ // this.dingtalkForm.items[index].props.value = this.form.nboCode
|
|
|
+ // this.dingtalkForm.items[index].props.disabled = true
|
|
|
+ // }
|
|
|
+ // if (this.dingtalkForm.items[index].props.label === '项目名称') {
|
|
|
+ // this.dingtalkForm.items[index].props.value = this.form.nboName
|
|
|
+ // this.dingtalkForm.items[index].props.disabled = true
|
|
|
+ // }
|
|
|
+ // if (this.dingtalkForm.items[index].props.label === '客户名称') {
|
|
|
+ // this.dingtalkForm.items[index].props.value = this.form.custName
|
|
|
+ // this.dingtalkForm.items[index].props.disabled = true
|
|
|
+ // }
|
|
|
+ // if (this.dingtalkForm.items[index].props.label === '所在省') {
|
|
|
+ // this.dingtalkForm.items[index].props.value = this.form.custProvince
|
|
|
+ // this.dingtalkForm.items[index].props.disabled = true
|
|
|
+ // }
|
|
|
+ // if (this.dingtalkForm.items[index].props.label === '所在市') {
|
|
|
+ // this.dingtalkForm.items[index].props.value = this.form.custCity
|
|
|
+ // this.dingtalkForm.items[index].props.disabled = true
|
|
|
+ // }
|
|
|
+ if (this.dingtalkForm.items[index].props.label === '销售工程师') {
|
|
|
+ this.dingtalkForm.items[index].props.value = this.form.saleName
|
|
|
+ this.dingtalkForm.items[index].props.disabled = true
|
|
|
+ }
|
|
|
+ if (this.dingtalkForm.items[index].props.label === '工单名称') {
|
|
|
+ let name = ''
|
|
|
+ if (this.form.dealerNames) {
|
|
|
+ name += this.form.dealerNames
|
|
|
+ }
|
|
|
+ if (this.form.agentNames) {
|
|
|
+ if (name == '') {
|
|
|
+ name += this.form.agentNames
|
|
|
+ } else {
|
|
|
+ name += ',' + this.form.agentNames
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.dingtalkForm.items[index].props.value = name + this.form.orderTypeName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$refs.dingTalkFrom.setFormAndRules(this.dingtalkForm)
|
|
|
+ },
|
|
|
+ // handleUploadFile(file) {
|
|
|
+ // this.form.file = file
|
|
|
+ // },
|
|
|
+ handleSelectUser() {
|
|
|
+ this.$refs.selectUser.open()
|
|
|
+ },
|
|
|
+ selectUser(val) {
|
|
|
+ if (val && val.length > 0) {
|
|
|
+ this.form.assignUserId = val[0].id
|
|
|
+ this.form.assignUserName = val.map((item) => item.nickName).join()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showEdit() {
|
|
|
+ this.getOrderTypeList()
|
|
|
+ this.loading = false
|
|
|
+ this.title = '添加'
|
|
|
+ this.form.saleId = this.userId
|
|
|
+ this.form.saleName = this.nickName
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ },
|
|
|
+ close() {
|
|
|
+ this.$refs['dingTalkFrom'].resetForm()
|
|
|
+ this.$refs['form'].resetFields()
|
|
|
+ this.form = this.$options.data().form
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ },
|
|
|
+ //
|
|
|
+ handleSelectDistributor(type) {
|
|
|
+ this.queryParams.distType = type
|
|
|
+ this.$refs.selectDistributor.open()
|
|
|
+ },
|
|
|
+ // 选中数据
|
|
|
+ saveDistributors(val) {
|
|
|
+ if (this.queryParams.distType == '10') {
|
|
|
+ if (val && val.length > 0) {
|
|
|
+ this.form.dealerIds = val.map((item) => item.id).join()
|
|
|
+ this.form.dealerNames = val.map((item) => item.distName).join()
|
|
|
+ } else {
|
|
|
+ this.form.dealerIds = ''
|
|
|
+ this.form.dealerNames = ''
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (val && val.length > 0) {
|
|
|
+ this.form.agentIds = val.map((item) => item.id).join()
|
|
|
+ this.form.agentNames = val.map((item) => item.distName).join()
|
|
|
+ } else {
|
|
|
+ this.form.agentIds = ''
|
|
|
+ this.form.agentNames = ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let temp = this.$refs['dingTalkFrom'].getFormData()
|
|
|
+ for (let index in temp.items) {
|
|
|
+ if (temp.items[index].props.label === '工单名称') {
|
|
|
+ let name = ''
|
|
|
+ if (this.form.dealerNames) {
|
|
|
+ name += this.form.dealerNames
|
|
|
+ }
|
|
|
+ if (this.form.agentNames) {
|
|
|
+ if (name == '') {
|
|
|
+ name += this.form.agentNames
|
|
|
+ } else {
|
|
|
+ name += ',' + this.form.agentNames
|
|
|
+ }
|
|
|
+ }
|
|
|
+ temp.items[index].props.value = name + this.form.orderTypeName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$refs.dingTalkFrom.setFormAndRules(temp)
|
|
|
+ },
|
|
|
+ save() {
|
|
|
+ let dingValid = this.$refs['dingTalkFrom'].validateForm()
|
|
|
+ this.$refs['form'].validate(async (valid) => {
|
|
|
+ if (valid && dingValid) {
|
|
|
+ if (!this.form.dealerNames && !this.form.agentNames) {
|
|
|
+ this.$message.warning('经销商、代理商不能全部为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let items = []
|
|
|
+ let dingtalkForm = this.$refs['dingTalkFrom'].getFormData()
|
|
|
+ for (let item of dingtalkForm.items) {
|
|
|
+ if (item.componentName === 'DDAttachment') {
|
|
|
+ if (!item.props && item.props.required) {
|
|
|
+ this.$baseMessage('请上传' + item.props.label, 'error', 'vab-hey-message-error')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.props.label === '工单名称') {
|
|
|
+ this.form.name = item.props.value
|
|
|
+ }
|
|
|
+ if (item.props.label === '备注' && !item.props.value) {
|
|
|
+ item.props.value = ''
|
|
|
+ }
|
|
|
+ if (item.props.label === '调研表上传' && !item.props.value) {
|
|
|
+ item.props.value = ''
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.props.label === '试用开始时间') {
|
|
|
+ this.form.trialTimeStart = item.props.value
|
|
|
+ }
|
|
|
+ if (item.props.label === '试用结束时间') {
|
|
|
+ this.form.trialTimeEnd = item.props.value
|
|
|
+ }
|
|
|
+ if (item.props.label === '期望完成时间') {
|
|
|
+ this.form.expectTime = item.props.value
|
|
|
+ }
|
|
|
+ if (item.props.label === '支持时间') {
|
|
|
+ this.form.supportTime = item.props.value
|
|
|
+ }
|
|
|
+ if (item.props.label === '支持人员') {
|
|
|
+ item.props.value = this.form.assignUserName
|
|
|
+ }
|
|
|
+ items.push({
|
|
|
+ componentName: item.componentName,
|
|
|
+ id: item.props.id,
|
|
|
+ name: item.props.label,
|
|
|
+ value: item.props.value,
|
|
|
+ required: item.props.required,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.form.formData = items
|
|
|
+ this.loading = true
|
|
|
+ const { msg } = await workApi.doAdd(this.form)
|
|
|
+ this.loading = false
|
|
|
+ this.$baseMessage(msg, 'success', 'vab-hey-message-success')
|
|
|
+ this.$emit('fetch-data')
|
|
|
+ this.close()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|