123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823 |
- <template>
- <a-modal
- :title="modalTitle"
- :width="900"
- :visible="visible"
- :confirmLoading="confirmLoading"
- class="ant-modal2"
- @cancel="handleCancel"
- >
- <a-form :form="form">
- <a-form-item v-show="false" >
- <a-input v-decorator="['id']" type="hidden"/>
- <a-input v-decorator="['sbId']" type="hidden"/>
- <a-input v-decorator="['partId']" type="hidden"/>
- </a-form-item>
- <row-list :col="2">
- <row-item>
- <a-form-item
- label="录入方式"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-radio-group v-decorator="['inputType', {initialValue: 2}]" button-style="solid" @change="inputTypeChange">
- <a-radio-button :value="2">
- 选择录入
- </a-radio-button>
- <a-radio-button :value="1">
- 手动录入
- </a-radio-button>
- </a-radio-group>
- </a-form-item>
- </row-item>
- <row-item v-if="inputType===2">
- <a-form-item
- label="设备名称"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- style="width: 70%"
- disabled
- v-decorator="['sbName', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
- <a-button style="width: 30%" type="primary" @click="handleSbSelect">选择</a-button>
- </a-form-item>
- </row-item>
- <row-item v-else>
- <a-form-item
- label="设备名称"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- v-decorator="['sbName']" />
- </a-form-item>
- </row-item>
- <row-item v-if="inputType===1">
- <a-form-item
- label="设备位号"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- v-decorator="['positionNo', {rules: [{required: true, message: '设备位号不能为空'}]}]" />
- </a-form-item>
- </row-item>
- <!-- <row-item>
- <a-form-item
- label="机电仪位号"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input v-decorator="['parentSbNo']" />
- </a-form-item>
- </row-item> -->
- <!-- <row-item>
- <a-form-item
- label="设备部位"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- style="width: 70%"
- disabled
- v-decorator="['partName']" />
- <a-button style="width: 30%" type="primary" @click="handlePartSelect">选择</a-button>
- </a-form-item>
- </row-item>-->
- <!-- <row-item>
- <a-form-item
- label="委托单位"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['trustDept', {rules: [{required: true, message: '委托单位不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in trustMap"
- :key="value"
- :label="label"
- :value="value">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item> -->
- <row-item>
- <a-form-item
- label="维修部门"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['repairDeptId', {rules: [{required: true, message: '维修部门不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in repairDeptMap"
- :key="value"
- :label="label"
- :value="value">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="维修专业"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-tree-select
- tree-checkable
- :show-checked-strategy="SHOW_PARENT"
- v-decorator="['repairProfessor', { rules: [{required: true, message: '检修专业不能为空'}]}]"
- placeholder="请选择">
- <a-tree-select-node
- v-for="(label,value) in professorMap"
- :key="value"
- :title="label"
- :value="parseInt(value)">{{ label }}
- </a-tree-select-node>
- </a-tree-select>
- </a-form-item>
- </row-item>
- <row-item v-if="inputType===1">
- <a-form-item
- label="车间位置"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['positionId', {rules: [{required: true, message: '车间位置不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="({id,name}) in sbPositionData"
- :key="id"
- :label="name"
- :value="id">{{ name }}
- </a-select-option>
- </a-select>
- <!-- <a-cascader
- :options="sbPositionList"
- :load-data="loadData"
- placeholder="请选择"
- change-on-select
- @change="sbPositionChange"
- v-decorator="['sbPosition', {rules: [{required: true, message: '车间位置不能为空'}]}]"
- /> -->
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="特殊作业类型"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-tree-select
- tree-checkable
- :show-checked-strategy="SHOW_PARENT"
- v-decorator="['repairType', {rules: [{required: true, message: '工作类型不能为空'}]}]"
- placeholder="请选择">
- <a-tree-select-node
- v-for="(label,value) in repairTypeMap"
- :key="value"
- :title="label"
- :value="parseInt(value)">{{ label }}
- </a-tree-select-node>
- </a-tree-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="车间具体位置"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- placeholder="比如:甲七车间北侧"
- v-decorator="['sbCph']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="工单类别"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select @change="changePlanFlag" v-decorator="['category', {initialValue: 2, rules: [{required: true, message: '工单类别不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in categoryMap"
- :key="value"
- :label="label"
- :value="parseInt(value)">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="是否停机"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['needStop', {rules: [{required: true, message: '是否停机不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in needStopMap"
- :key="value"
- :label="label"
- :value="parseInt(value)">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item v-if="category === 1">
- <a-form-item
- label="计划性维修级别"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['repairPlanLevel', {rules: [{required: true, message: '计划性维修级别不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="value in ['大','中','小']"
- :key="value"
- :label="value"
- :value="value">{{ value }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item v-if="category === 1">
- <a-form-item
- label="审批人"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['dispatchUserId', {rules: [{required: true, message: '审批人不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="({realName,userId}) in dispatchUserList"
- :key="userId"
- :label="realName"
- :value="userId">{{ realName }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <!-- <row-item v-show="category === 1">
- <a-form-item
- label="要求日期"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-date-picker
- style="width: 100%"
- :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
- v-decorator="['limitDate']" />
- </a-form-item>
- </row-item> -->
- <!-- <row-item v-show="category === 2">
- <a-form-item
- label="要求时间"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- style="width: 100%"
- suffix="小时"
- v-decorator="['limitHours', {rules: [{required: true, message: '要求时间不能为空'}]}]" />
- </a-form-item>
- </row-item> -->
- <row-item>
- <a-form-item
- label="计划开始时间"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-date-picker
- style="width: 100%"
- :show-time="{ format: 'HH:mm' }"
- :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN2"
- v-decorator="['planStartTime', {rules: [{required: true, message: '计划开始时间不能为空'}]}]" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="计划结束时间"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-date-picker
- style="width: 100%"
- :show-time="{ format: 'HH:mm' }"
- :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN2"
- v-decorator="['planEndTime', {rules: [{required: true, message: '计划结束时间不能为空'}]}]" />
- </a-form-item>
- </row-item>
- <row-item v-if="category !== 1">
- <a-form-item
- label="工作优选权"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['level', {initialValue: 1, rules: [{required: true, message: '工作优选权不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in levelMap"
- :key="value"
- :label="label"
- :value="parseInt(value)">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="报修人"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- disabled="disabled"
- v-decorator="['actualUser', {initialValue: userInfo.realName, rules: [{required: true, message: '报修人不能为空'}]}]"/>
- </a-form-item>
- </row-item>
- <!-- <row-item>
- <a-form-item
- label="紧急等级"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['level', {initialValue: 1, rules: [{required: true, message: '紧急等级不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in levelMap"
- :key="value"
- :label="label"
- :value="parseInt(value)">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="异常类别"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-tree-select
- style="width: 100%"
- :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
- :treeData="treeData"
- :treeNodeFilterProp="'title'"
- :showSearch="true"
- v-decorator="['repairErrorTypeId']"
- placeholder="请选择"
- >
- </a-tree-select>
- </a-form-item>
- </row-item>-->
- <row-item>
- <a-form-item
- label="报修图片"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-upload
- :action="uploadUrl"
- :multiple="true"
- list-type="picture"
- :file-list="this.defaultApplicationFileList"
- @change="handleApplicationFileChange"
- accept="image/*"
- :headers="headers"
- >
- <a-button> <a-icon type="upload" /> 上传图片 </a-button>
- </a-upload>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="资料文件"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-upload
- :action="uploadUrl"
- :multiple="true"
- :file-list="defaultCheckFileList"
- @change="handleCheckFileChange"
- :headers="headers"
- >
- <a-button> <a-icon type="upload" /> 上传 </a-button>
- </a-upload>
- </a-form-item>
- </row-item>
- <row-item v-show="refusedFlag">
- <a-form-item
- label="驳回原因"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- disabled="disabled"
- v-decorator="['remark']"/>
- </a-form-item>
- </row-item>
- </row-list>
- <row-list :col="1">
- <row-item v-if="false">
- <a-form-item
- label="报修状态"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select disabled v-decorator="['status', {initialValue: DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED,rules: [{required: true, message: '报修状态不能为空'}]}]" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in statusMap"
- :key="value"
- :label="label"
- :value="parseInt(value)">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <!-- <row-item>
- <a-form-item
- label="故障描述"
- :labelCol="BaseTool.Constant.labelCol2"
- :wrapperCol="BaseTool.Constant.wrapperCol2"
- >
- <a-select v-decorator="['content']" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in questionMap"
- :key="value"
- :label="label"
- :value="parseInt(value)">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>-->
- <row-item>
- <a-form-item
- label="委托内容描述"
- :labelCol="BaseTool.Constant.labelCol2"
- :wrapperCol="BaseTool.Constant.wrapperCol2"
- >
- <a-textarea
- :rows="4"
- v-decorator="['content', {rules: [{required: true, message: '委托内容描述不能为空'}]}]"/>
- </a-form-item>
- </row-item>
- </row-list>
- </a-form>
- <template slot="footer">
- <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
- </template>
- <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
- <part-info-select-modal ref="partInfoSelectModal" @selected="handlePartSelected"/>
- </a-modal>
- </template>
- <script>
- import pick from 'lodash.pick'
- import BaseTool from '../../../../utils/tool'
- import { addRepairApplicationForm, updateRepairApplicationForm, getSbPositions, getDispatchUser, receiveProfessor } from '@/api/repair/application-form'
- import PartInfoSelectModal from '@/views/part/info/modules/PartInfoSelectModal'
- import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
- import { queryUser } from '@/api/upms/user'
- import { uploadUrl } from '@/api/upms/file'
- import Vue from 'vue'
- import { ACCESS_TOKEN } from '@/store/mutation-types'
- import { fetchErrorTypeTree } from '@/api/repair/errortype'
- import { querySbPosition } from '@/api/sb/position'
- import { TreeSelect } from 'ant-design-vue'
- const SHOW_PARENT = TreeSelect.SHOW_PARENT
- export default {
- name: 'BaseRepairApplicationForm',
- data () {
- return {
- SHOW_PARENT,
- confirmLoading: false,
- modalTitle: null,
- inputType: 2,
- positionId: '',
- professorMap: {},
- repairTypeMap: {},
- sbPositionList: [],
- form: this.$form.createForm(this),
- visible: false,
- sbId: null,
- // 下拉框map
- sourceMap: {},
- levelMap: {},
- questionMap: {},
- dispatchUserList: {},
- treeData: [],
- sbPositionData: [],
- needStop: null,
- needStopMap: {},
- category: 0,
- categoryMap: {},
- trustMap: {},
- statusMap: {},
- userInfo: this.$store.getters.userInfo,
- userList: [],
- uploadUrl: uploadUrl,
- defaultRepairFileList: [],
- defaultApplicationFileList: [],
- defaultCheckFileList: [],
- applicationFileList: [], // 报修图片
- reportFileList: [], // 审核图片
- repairFileList: [], // 维修图片,
- repairDeptMap: {},
- refusedFlag: false,
- headers: {
- Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
- }
- }
- },
- components: {
- SbInfoSelectModal,
- PartInfoSelectModal
- },
- props: {
- },
- created () {
- // 下拉框map
- this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
- // this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
- this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
- this.questionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_QUESTION)
- this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
- this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LEVEL_TYPE)
- this.categoryMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
- this.trustMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.TRUST_DEPT_TYPE)
- console.log(this.categoryMap)
- this.repairDeptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_DEPT_CATEGORY)
- this.repairTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_TYPE)
- this.professorMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_PROFESSOR)
- this.getUsers()
- this.getSbPositions()
- querySbPosition().then(res => {
- this.sbPositionData = res.data
- })
- },
- methods: {
- base (record) {
- this.visible = true
- this.refusedFlag = false
- fetchErrorTypeTree().then(res => {
- this.treeData = res.data
- })
- // 如果是空标识添加
- if (this.BaseTool.Object.isBlank(record)) {
- this.modalTitle = '报修'
- if (!this.BaseTool.Object.isBlank(record) && !this.BaseTool.Object.isBlank(record.sbId)) {
- const { form: { setFieldsValue } } = this
- this.$nextTick(() => {
- setFieldsValue(Object.assign(pick(record, [
- 'sbId',
- 'sbName'
- ])))
- })
- }
- return
- }
- if (this.BaseTool.Object.isBlank(record.id)) {
- this.modalTitle = '报修'
- if (!this.BaseTool.Object.isBlank(record.sbId)) {
- const { form: { setFieldsValue } } = this
- this.$nextTick(() => {
- setFieldsValue(Object.assign(pick(record, [
- 'sbId',
- 'sbName',
- 'sbCph'
- ])))
- })
- }
- return
- }
- this.modalTitle = '编辑'
- this.applicationFileList = record.applicationFileList
- this.repairFileList = record.repairFileList
- this.reportFileList = record.reportFileList
- this.defaultApplicationFileList = this.BaseTool.UPLOAD.transImg(this.applicationFileList)
- this.defaultRepairFileList = this.BaseTool.UPLOAD.transImg(this.repairFileList)
- this.defaultCheckFileList = this.BaseTool.UPLOAD.transImg(this.reportFileList)
- if (record.status === this.DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REFUSED_REPAIR) {
- this.refusedFlag = true
- }
- const { form: { setFieldsValue } } = this
- // 日期处理
- record.applyTime = this.BaseTool.Moment(record.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
- if (record.limitDate != null) {
- record.limitDate = this.BaseTool.Moment(record.limitDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- this.$nextTick(() => {
- setFieldsValue(Object.assign(pick(record, [
- 'limitDate'
- ])))
- })
- }
- this.$nextTick(() => {
- setFieldsValue(Object.assign(pick(record, [
- 'id',
- 'sbId',
- 'sbCph',
- 'partId',
- 'repairUserId',
- 'no',
- 'category',
- 'limitDate',
- 'limitHours',
- 'source',
- 'level',
- 'content',
- 'status',
- 'sbName',
- 'needStop',
- 'category',
- 'partName',
- 'remark',
- 'repairDeptId'
- ])))
- })
- },
- getSbPositions (parentId) {
- getSbPositions({ parentId }).then(res => {
- console.log(res)
- this.sbPositionList = res.data.map(item => {
- item = {
- label: item.name,
- value: item.name,
- id: item.id,
- isLeaf: false
- }
- return item
- })
- })
- },
- loadData (selectedOptions) {
- console.log(selectedOptions)
- const targetOption = selectedOptions[selectedOptions.length - 1]
- targetOption.loading = true
- getSbPositions({ parentId: targetOption.id }).then(res => {
- targetOption.loading = false
- targetOption.children = res.data.map(item => {
- item = {
- label: item.name,
- value: item.name,
- id: item.id
- }
- return item
- })
- this.sbPositionList = [...this.sbPositionList]
- })
- },
- getUsers () {
- queryUser({ status: 1 }).then(res => {
- this.userList = res.data
- })
- getDispatchUser().then(res => {
- console.log(res)
- this.dispatchUserList = res.data
- })
- },
- save () {
- const { form: { validateFieldsAndScroll } } = this
- this.confirmLoading = true
- validateFieldsAndScroll((errors, values) => {
- if (errors) {
- this.confirmLoading = false
- return
- }
- // 日期处理
- values.applyTime = this.BaseTool.Date.formatter(values.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
- values.limitDate = BaseTool.Date.formatter(values.limitDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- values.planStartTime = BaseTool.Date.formatter(values.planStartTime, BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
- values.planEndTime = BaseTool.Date.formatter(values.planEndTime, BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
- // 上传文件
- values.repairFileList = this.repairFileList
- values.repairProfessor = values.repairProfessor.join(',')
- values.repairType = values.repairType.join(',')
- values.applicationFileList = this.applicationFileList
- values.reportFileList = this.reportFileList
- // values.sbPosition = values.sbPosition.join('->')
- console.log(values)
- if (values.partId === undefined) {
- values.partId = ''
- }
- if (values.category === 2) { // 非计划性维修
- values.source = 2
- } else {
- values.source = 1
- }
- if (this.BaseTool.String.isBlank(values.id)) {
- addRepairApplicationForm(values)
- .then(() => {
- this.$notification.success({
- message: '报修成功!',
- duration: 3
- })
- this.handleCancel(values)
- }).catch(() => {
- this.confirmLoading = false
- })
- } else {
- updateRepairApplicationForm(values)
- .then(() => {
- this.handleCancel(values)
- }).catch(() => {
- this.confirmLoading = false
- })
- }
- })
- },
- changePlanFlag (value) {
- this.category = value
- const { form: { setFieldsValue } } = this
- if (this.category === 1) {
- this.$nextTick(() => {
- setFieldsValue({ needStop: 1 })
- })
- } else {
- this.$nextTick(() => {
- setFieldsValue({ needStop: 0 })
- })
- }
- },
- handleCancel (values) {
- this.visible = false
- this.confirmLoading = false
- this.applicationFileList = []
- this.defaultApplicationFileList = []
- this.form.resetFields()
- if (this.BaseTool.Object.isNotBlank(values)) {
- this.$emit('ok', values)
- }
- },
- handleSbSelect () {
- this.$refs.sbInfoSelectModal.base({}, {})
- },
- handleSbSelectd (keys, rows) {
- const [ key ] = keys
- const [ row ] = rows
- const { form: { setFieldsValue } } = this
- this.sbId = key
- // 日期处理
- receiveProfessor({ id: key }).then(res => {
- const val = res.data ? res.data : 1
- this.$nextTick(() => {
- setFieldsValue(Object.assign({
- 'sbId': key,
- 'sbName': row.name,
- 'sbCph': row.cph,
- 'repairProfessor': [val]
- // 'parentSbNo': row.ppNo
- }))
- })
- })
- },
- handlePartSelect () {
- if (this.sbId === null) {
- return this.$message.error('选择设备部位之前,请选择设备')
- }
- this.$refs.partInfoSelectModal.base({ sbId: this.sbId })
- },
- handlePartSelected (keys, rows) {
- const [ key ] = keys
- const [ row ] = rows
- const { form: { setFieldsValue } } = this
- this.$nextTick(() => {
- setFieldsValue(Object.assign({
- 'partId': key,
- 'partName': row.name
- }))
- })
- },
- handleCheckFileChange (info) {
- this.defaultCheckFileList = info.fileList
- this.reportFileList = this.setFileList(info, 32)
- },
- handleApplicationFileChange (info) {
- this.defaultApplicationFileList = info.fileList
- this.applicationFileList = this.setFileList(info, 11)
- },
- setFileList (info, type) {
- const file = info.file
- const fileList = info.fileList
- if (file.status === 'done') {
- return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
- } else if (file.status === 'removed') {
- return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
- } else if (file.status === 'error') {
- this.$message.error('上传失败')
- return []
- }
- },
- inputTypeChange (e) {
- this.inputType = e.target.value
- this.form.resetFields()
- },
- sbPositionChange (e, val) {
- this.positionId = val[val.length - 1].id
- }
- }
- }
- </script>
|