122 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
		
		
			
		
	
	
			122 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
|   | <template> | |||
|  |   <a-modal | |||
|  |     title="编辑作业票" | |||
|  |     :width="900" | |||
|  |     :visible="visible" | |||
|  |     :confirmLoading="confirmLoading" | |||
|  |     @ok="handleSubmit" | |||
|  |     @cancel="handleCancel" | |||
|  |   > | |||
|  |     <a-spin :spinning="confirmLoading"> | |||
|  |       <a-form :form="form"> | |||
|  |         <a-form-item v-show="false"><a-input v-decorator="['id']" /></a-form-item> | |||
|  |         <a-form-item | |||
|  |           label="8大作业票" | |||
|  |           :labelCol="labelCol" | |||
|  |           :wrapperCol="wrapperCol" | |||
|  |         > | |||
|  |           <a-select style="width: 100%" placeholder="请选择8大作业票" v-decorator="['name', {rules: [{ required: true, message: '请选择8大作业票!' }]}]"> | |||
|  |             <a-select-option v-for="(item,index) in nameData" :key="index" :value="item.code">{{ item.name }}</a-select-option> | |||
|  |           </a-select> | |||
|  |         </a-form-item> | |||
|  |         <a-form-item | |||
|  |           label="年" | |||
|  |           :labelCol="labelCol" | |||
|  |           :wrapperCol="wrapperCol" | |||
|  |           has-feedback | |||
|  |         > | |||
|  |           <a-input-number placeholder="请输入年" style="width: 100%" v-decorator="['year', {rules: [{required: true, message: '请输入年!'}]}]" /> | |||
|  |         </a-form-item> | |||
|  |         <a-form-item | |||
|  |           label="月份" | |||
|  |           :labelCol="labelCol" | |||
|  |           :wrapperCol="wrapperCol" | |||
|  |           has-feedback | |||
|  |         > | |||
|  |           <a-input-number placeholder="请输入月份" style="width: 100%" v-decorator="['month', {rules: [{required: true, message: '请输入月份!'}]}]" /> | |||
|  |         </a-form-item> | |||
|  |         <a-form-item | |||
|  |           label="数量" | |||
|  |           :labelCol="labelCol" | |||
|  |           :wrapperCol="wrapperCol" | |||
|  |           has-feedback | |||
|  |         > | |||
|  |           <a-input-number placeholder="请输入数量" style="width: 100%" v-decorator="['totalNum', {rules: [{required: true, message: '请输入数量!'}]}]" /> | |||
|  |         </a-form-item> | |||
|  |       </a-form> | |||
|  |     </a-spin> | |||
|  |   </a-modal> | |||
|  | </template> | |||
|  | 
 | |||
|  | <script> | |||
|  |   import { scrWorkTaskEdit } from '@/api/modular/main/scrworktask/scrWorkTaskManage' | |||
|  |   export default { | |||
|  |     data () { | |||
|  |       return { | |||
|  |         labelCol: { | |||
|  |           xs: { span: 24 }, | |||
|  |           sm: { span: 5 } | |||
|  |         }, | |||
|  |         wrapperCol: { | |||
|  |           xs: { span: 24 }, | |||
|  |           sm: { span: 15 } | |||
|  |         }, | |||
|  |         nameData: [], | |||
|  |         visible: false, | |||
|  |         confirmLoading: false, | |||
|  |         form: this.$form.createForm(this) | |||
|  |       } | |||
|  |     }, | |||
|  |     methods: { | |||
|  |       // 初始化方法
 | |||
|  |       edit (record) { | |||
|  |         this.visible = true | |||
|  |         const nameOption = this.$options | |||
|  |         this.nameData = nameOption.filters['dictData']('work_task_type') | |||
|  |         setTimeout(() => { | |||
|  |           this.form.setFieldsValue( | |||
|  |             { | |||
|  |               id: record.id, | |||
|  |               name: record.name, | |||
|  |               year: record.year, | |||
|  |               month: record.month, | |||
|  |               totalNum: record.totalNum | |||
|  |             } | |||
|  |           ) | |||
|  |         }, 100) | |||
|  |       }, | |||
|  |       handleSubmit () { | |||
|  |         const { form: { validateFields } } = this | |||
|  |         this.confirmLoading = true | |||
|  |         validateFields((errors, values) => { | |||
|  |           if (!errors) { | |||
|  |             for (const key in values) { | |||
|  |               if (typeof (values[key]) === 'object' && values[key] != null) { | |||
|  |                 values[key] = JSON.stringify(values[key]) | |||
|  |               } | |||
|  |             } | |||
|  |             scrWorkTaskEdit(values).then((res) => { | |||
|  |               if (res.success) { | |||
|  |                 this.$message.success('编辑成功') | |||
|  |                 this.confirmLoading = false | |||
|  |                 this.$emit('ok', values) | |||
|  |                 this.handleCancel() | |||
|  |               } else { | |||
|  |                 this.$message.error('编辑失败')//  + res.message
 | |||
|  |               } | |||
|  |             }).finally((res) => { | |||
|  |               this.confirmLoading = false | |||
|  |             }) | |||
|  |           } else { | |||
|  |             this.confirmLoading = false | |||
|  |           } | |||
|  |         }) | |||
|  |       }, | |||
|  |       handleCancel () { | |||
|  |         this.form.resetFields() | |||
|  |         this.visible = false | |||
|  |       } | |||
|  |     } | |||
|  |   } | |||
|  | </script> |