123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <template>
- <a-modal
- centered
- class="departUser-modal"
- :footer="null"
- :maskClosable="false"
- :title="title+'选择审批人员'"
- v-model="isShow"
- @cancel="cancel"
- width="60%">
- <a-spin :spinning="spinning" tip="Loading...">
- <div>
- <div class="departUser-con">
- <a-form-model
- id="departUser-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol">
- <a-form-model-item label="退货类型" prop="salesReturnType">
- <v-select
- v-model="form.salesReturnType"
- id="departUser-salesReturnType"
- code="SALES_RETURN_TYPE"
- placeholder="请选择退货类型"
- allowClear></v-select>
- </a-form-model-item>
- <a-form-model-item label="申请人员" prop="applyPersonSn">
- <employee style="width: 100%;" @change="employeeChange" id="departUser-Employee" v-model="form.applyPersonSn"></employee>
- </a-form-model-item>
- <a-form-model-item label="审批人员" prop="approvers">
- <dingDepartUser
- ref="departUserApp"
- @loaded="uploading=false"
- id="departUser-approvers"
- :disabled="uploading"
- v-model="form.approvers"
- @change="changeApprovers"
- allowClear
- placeholder="请选择审批人员"
- ></dingDepartUser>
- </a-form-model-item>
- <a-form-model-item label="抄送人" prop="ccList">
- <dingDepartUser
- ref="departUserCc"
- @loaded="uploading=false"
- :disabled="uploading"
- id="departUser-ccList"
- v-model="form.ccList"
- allowClear
- placeholder="请选择抄送人"
- ></dingDepartUser>
- </a-form-model-item>
- <a-form-model-item label="附件" help="(支持图片、word、excel、PDF等格式,最多10个附件)">
- <Upload
- style="height: 100%;"
- v-model="form.attachmentList"
- ref="attachList"
- :fileSize="10"
- :maxNums="10"
- fileType="*"
- uploadType="attach"
- :action="attachAction"
- @change="changeAttach"
- upText="上传附件"></Upload>
- </a-form-model-item>
- </a-form-model>
- </div>
- <div class="btn-cont">
- <a-button type="primary" id="departUser-save" @click="handleSave">确定</a-button>
- <a-button :loading="uploading" style="margin-left: 15px;" @click="updateUser">刷新人员</a-button>
- <a-button id="departUser-back" @click="cancel" style="margin-left: 15px;">取消</a-button>
- </div>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { VSelect, Upload } from '@/components'
- import dingDepartUser from '@/views/common/dingDepartUser.js'
- import employee from '@/views/expenseManagement/expenseReimbursement/employee.js'
- import { sign } from 'core-js/fn/number'
- export default {
- name: 'ChooseDepartUserModal',
- components: { dingDepartUser, employee, VSelect, Upload },
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- }
- },
- data () {
- return {
- uploading: false,
- spinning: false,
- isShow: this.openModal, // 是否打开弹框
- title: '',
- formItemLayout: {
- labelCol: { span: 4 },
- wrapperCol: { span: 16 }
- },
- form: {
- salesReturnType: undefined,
- applyPersonSn: undefined,
- approvers: [], // 审批人
- ccList: [] // 抄送人
- },
- attachList: [],
- attachAction: process.env.VUE_APP_API_BASE_URL + '/uploadGetFileInfo',
- rules: {
- salesReturnType: [
- { required: true, message: '请选择退货类型', trigger: 'change' }
- ],
- applyPersonSn: [
- { required: true, message: '请选择申请人员', trigger: 'change' }
- ],
- approvers: [
- { required: true, type: 'array', message: '请选择审批人', trigger: 'change' }
- ]
- }
- }
- },
- methods: {
- // 申请人员
- employeeChange (v, r) {
- this.$nextTick(() => {
- this.$refs.ruleForm.validateField(['applyPersonSn'])
- })
- },
- // 附件上传
- changeAttach (file) {
- this.attachList = JSON.parse(file)
- this.attachList.map(item => {
- item.fileType = item.extName
- })
- },
- updateUser () {
- this.uploading = true
- this.$refs.departUserApp.updateDeptUser()
- // this.$refs.departUserCc.updateDeptUser()
- },
- changeApprovers (value) {
- this.form.approvers = value
- this.$refs.ruleForm.clearValidate()
- },
- getTreeVal (data) {
- const ret = []
- data.map(item => {
- ret.push(item.value)
- })
- return ret.join(',')
- },
- // 确定
- handleSave (e) {
- e.preventDefault()
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const form = JSON.parse(JSON.stringify(_this.form))
- form.attachmentList = this.attachList
- if (form.approvers) {
- form.approvers = this.getTreeVal(form.approvers)
- }
- if (form.ccList) {
- form.ccList = this.getTreeVal(form.ccList)
- }
- console.log(form)
- this.$emit('submit', form)
- this.$emit('close')
- } else {
- return false
- }
- })
- },
- getDetail (data) {
- this.form = Object.assign(this.form, {
- salesReturnType: data.salesReturnType,
- applyPersonSn: data.applyPersonSn
- })
- // 获取附件列表
- this.form.attachmentList = ''
- this.attachList = data.attachmentList
- this.$nextTick(() => {
- if (this.attachList.length) {
- this.$refs.attachList.setFileList(this.attachList)
- }
- })
- },
- resetForm () {
- this.$nextTick(() => {
- this.$refs.ruleForm.resetFields()
- this.$refs.attachList.setFileList('')
- })
- this.attachList = []
- this.form = {
- salesReturnType: undefined,
- applyPersonSn: undefined,
- ccList: undefined,
- approvers: undefined,
- attachmentList: ''
- }
- },
- cancel () {
- this.isShow = false
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.resetForm()
- }
- }
- }
- }
- </script>
- <style lang="less">
- .departUser-modal{
- .ant-modal-body {
- padding: 30px 40px 24px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|