| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <template>
- <a-modal
- :title="modalTitle"
- :width="800"
- :visible="visible"
- :confirmLoading="confirmLoading"
- @cancel="handleCancel"
- >
- <a-form :form="form">
- <row-list :col="2">
- <row-item>
- <a-form-item
- label="维修负责人"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <div style="position: relative;">
- <a-input
- v-model="searchKeyword"
- placeholder="点击选择维修负责人"
- readonly
- @click="showDropdown = !showDropdown"
- >
- <a-icon
- slot="suffix"
- type="down"
- @click="showDropdown = !showDropdown"
- />
- </a-input>
- <div
- v-if="showDropdown"
- style="
- position: absolute;
- top: 100%;
- left: 0;
- right: 0;
- background: #fff;
- border: 1px solid #d9d9d9;
- border-radius: 4px;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
- max-height: 300px;
- overflow-y: auto;
- z-index: 1000;
- margin-top: 4px;
- "
- @mouseleave="onDropdownMouseLeave"
- >
- <div style="padding: 8px; border-bottom: 1px solid #f0f0f0; position: sticky; top: 0; background: #fff; z-index: 1;">
- <a-input
- v-model="filterKeyword"
- placeholder="搜索姓名"
- size="small"
- @click.stop
- />
- </div>
- <div
- v-for="item in filteredDeptUserList"
- :key="item.userId"
- @click="selectUser(item)"
- :style="{
- padding: '8px 12px',
- cursor: 'pointer',
- background: selectedUserId === item.userId ? '#e6f7ff' : 'transparent'
- }"
- @mouseenter="($event.target.style.background = selectedUserId === item.userId ? '#e6f7ff' : '#f5f5f5')"
- @mouseleave="($event.target.style.background = selectedUserId === item.userId ? '#e6f7ff' : 'transparent')"
- >
- {{ item.realName }}
- </div>
- <div v-if="filteredDeptUserList.length === 0" style="padding: 16px; text-align: center; color: #999;">
- 无匹配结果
- </div>
- </div>
- </div>
- </a-form-item>
- </row-item>
- </row-list>
- <row-list :col="1">
- <row-item>
- <a-form-item
- label="备注"
- :labelCol="BaseTool.Constant.labelCol2"
- :wrapperCol="BaseTool.Constant.wrapperCol2"
- >
- <a-textarea
- :rows="4"
- v-decorator="['repairDispatchRemark']"/>
- </a-form-item>
- </row-item>
- </row-list>
- </a-form>
- <template slot="footer">
- <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
- </template>
- </a-modal>
- </template>
- <script>
- import { dispatchModelByDTO } from '@/api/repair/application-form'
- import { queryUserDept } from '@/api/upms/user-dept'
- import { queryUser } from '@/api/upms/user'
- export default {
- name: 'DispatchForm',
- data () {
- return {
- confirmLoading: false,
- modalTitle: null,
- form: this.$form.createForm(this),
- visible: false,
- sourceMap: {},
- levelMap: {},
- statusMap: {},
- record: {},
- userList: [],
- deptUserList: [],
- showDropdown: false,
- searchKeyword: '',
- filterKeyword: '',
- selectedUserId: null,
- selectedUserName: ''
- }
- },
- computed: {
- filteredDeptUserList () {
- if (!this.filterKeyword) {
- return this.deptUserList
- }
- return this.deptUserList.filter(item =>
- item.realName.toLowerCase().includes(this.filterKeyword.toLowerCase())
- )
- }
- },
- created () {
- 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.getUsers()
- this.getDeptUsers()
- },
- mounted () {
- document.addEventListener('click', this.handleDocumentClick)
- },
- beforeDestroy () {
- document.removeEventListener('click', this.handleDocumentClick)
- },
- methods: {
- handleDocumentClick (e) {
- if (this.showDropdown && !e.target.closest('.ant-input-affix-wrapper')) {
- this.showDropdown = false
- }
- },
- onDropdownMouseLeave () {
- },
- selectUser (item) {
- this.selectedUserId = item.userId
- this.selectedUserName = item.realName
- this.searchKeyword = item.realName
- this.showDropdown = false
- this.form.setFieldsValue({ repairUserId: item.userId })
- },
- base (record) {
- this.visible = true
- this.modalTitle = '派工'
- this.record = record
- this.$nextTick(() => {
- this.form.resetFields()
- this.selectedUserId = null
- this.selectedUserName = ''
- this.searchKeyword = ''
- this.filterKeyword = ''
- this.showDropdown = false
- })
- },
- getDeptUsers () {
- queryUserDept({ deptCode: this.DictCache.VALUE.SYS_DEPT_CODE.XIAN_CHANG_WEI_XIU_ZU, userStatus: 1 }).then(res => {
- queryUserDept({ deptCode: this.DictCache.VALUE.SYS_DEPT_CODE.CHANG_NEI_WEI_XIU_ZU, userStatus: 1 }).then(res2 => {
- this.deptUserList = res.data.concat(res2.data)
- })
- })
- },
- getUsers () {
- queryUser({ status: 1 }).then(res => {
- this.userList = res.data
- })
- },
- save () {
- if (!this.selectedUserId) {
- this.$message.warning('请选择维修负责人')
- return
- }
- const { form: { validateFieldsAndScroll } } = this
- this.confirmLoading = true
- validateFieldsAndScroll((errors, values) => {
- if (errors) {
- this.confirmLoading = false
- return
- }
- values.id = this.record.id
- values.repairUserId = this.selectedUserId
- dispatchModelByDTO(values)
- .then(() => {
- this.handleCancel(values)
- }).catch(() => {
- this.confirmLoading = false
- })
- })
- },
- handleCancel (values) {
- this.visible = false
- this.confirmLoading = false
- this.form.resetFields()
- if (this.BaseTool.Object.isNotBlank(values)) {
- this.$emit('ok')
- }
- }
- }
- }
- </script>
|