BaseOutForm.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="800"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. >
  10. <a-form :form="form">
  11. <a-form-item v-show="false" >
  12. <a-input v-decorator="['id']" type="hidden"/>
  13. </a-form-item>
  14. <row-list :col="2">
  15. <row-item>
  16. <a-form-item
  17. label="委外订单号"
  18. :labelCol="BaseTool.Constant.labelCol"
  19. :wrapperCol="BaseTool.Constant.wrapperCol"
  20. >
  21. <a-input
  22. v-decorator="['outNo', {rules: [{required: false, message: '委外订单号不能为空'}]}]"/>
  23. </a-form-item>
  24. </row-item>
  25. <row-item>
  26. <a-form-item
  27. label="委外类别"
  28. :labelCol="BaseTool.Constant.labelCol"
  29. :wrapperCol="BaseTool.Constant.wrapperCol"
  30. >
  31. <a-select v-decorator="['outType']" placeholder="请选择">
  32. <a-select-option
  33. v-for="(label,value) in outTypeMap"
  34. :key="value"
  35. :label="label"
  36. :value="parseInt(value)">{{ label }}
  37. </a-select-option>
  38. </a-select>
  39. </a-form-item>
  40. </row-item>
  41. <row-item>
  42. <a-form-item
  43. label="维修负责人"
  44. :labelCol="BaseTool.Constant.labelCol"
  45. :wrapperCol="BaseTool.Constant.wrapperCol"
  46. >
  47. <a-select v-decorator="['repairUserId', {rules: [{required: true, message: '维修人负责人不能为空'}]}]" placeholder="请选择">
  48. <a-select-option
  49. v-for="item in deptUserList"
  50. :key="item.userId"
  51. :label="item.realName"
  52. :value="item.userId">{{ item.realName }}
  53. </a-select-option>
  54. </a-select>
  55. </a-form-item>
  56. </row-item>
  57. </row-list>
  58. <row-list :col="1">
  59. <row-item>
  60. <a-form-item
  61. label="故障描述"
  62. :labelCol="BaseTool.Constant.labelCol2"
  63. :wrapperCol="BaseTool.Constant.wrapperCol2"
  64. >
  65. <a-textarea
  66. :rows="4"
  67. v-decorator="['content']"/>
  68. </a-form-item>
  69. </row-item>
  70. </row-list>
  71. </a-form>
  72. <template slot="footer">
  73. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  74. </template>
  75. </a-modal>
  76. </template>
  77. <script>
  78. import pick from 'lodash.pick'
  79. import { queryUserDept } from '@/api/upms/user-dept'
  80. import { addRepairApplicationForm, updateRepairApplicationForm } from '@/api/repair/application-form'
  81. import PartInfoSelectModal from '@/views/part/info/modules/PartInfoSelectModal'
  82. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  83. export default {
  84. name: 'BaseRepairApplicationForm',
  85. data () {
  86. return {
  87. confirmLoading: false,
  88. modalTitle: null,
  89. form: this.$form.createForm(this),
  90. visible: false,
  91. // 下拉框map
  92. sourceMap: {},
  93. outTypeMap: {},
  94. levelMap: {},
  95. questionMap: {},
  96. needStopMap: {},
  97. statusMap: {},
  98. userInfo: this.$store.getters.userInfo,
  99. deptUserList: []
  100. }
  101. },
  102. components: {
  103. SbInfoSelectModal,
  104. PartInfoSelectModal
  105. },
  106. props: {
  107. },
  108. created () {
  109. // 下拉框map
  110. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  111. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  112. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  113. this.questionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_QUESTION)
  114. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  115. this.outTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_OUT_TYPE)
  116. this.getDeptUsers()
  117. },
  118. methods: {
  119. base (record, mainForm = {}) {
  120. this.visible = true
  121. // 如果是空标识添加
  122. const { form: { setFieldsValue } } = this
  123. if (this.BaseTool.Object.isBlank(record)) {
  124. this.modalTitle = '添加'
  125. if (mainForm != null && mainForm.id != null) {
  126. this.$nextTick(() => {
  127. setFieldsValue({
  128. id: mainForm.id
  129. })
  130. })
  131. }
  132. return
  133. }
  134. this.modalTitle = '编辑'
  135. // 日期处理
  136. this.$nextTick(() => {
  137. setFieldsValue(Object.assign(pick(record, [
  138. 'id',
  139. 'sbId',
  140. 'partId',
  141. 'type',
  142. 'outType',
  143. 'mainRepairId',
  144. 'repairUserId',
  145. 'outNo',
  146. 'source',
  147. 'level',
  148. 'content',
  149. 'status',
  150. 'sbName',
  151. 'partName',
  152. 'remark'
  153. ])))
  154. })
  155. },
  156. getDeptUsers () {
  157. queryUserDept({ deptCode: this.DictCache.VALUE.SYS_DEPT_CODE.CHANG_NEI_WEI_XIU_ZU, userStatus: 1 }).then(res2 => {
  158. this.deptUserList = res2.data
  159. })
  160. },
  161. save () {
  162. const { form: { validateFieldsAndScroll } } = this
  163. this.confirmLoading = true
  164. validateFieldsAndScroll((errors, values) => {
  165. if (errors) {
  166. this.confirmLoading = false
  167. return
  168. }
  169. values.type = 2
  170. if (this.BaseTool.String.isBlank(values.id)) {
  171. addRepairApplicationForm(values)
  172. .then(() => {
  173. this.handleCancel(values)
  174. }).catch(() => {
  175. this.confirmLoading = false
  176. })
  177. } else {
  178. updateRepairApplicationForm(values)
  179. .then(() => {
  180. this.handleCancel(values)
  181. }).catch(() => {
  182. this.confirmLoading = false
  183. })
  184. }
  185. })
  186. },
  187. handleCancel (values) {
  188. this.visible = false
  189. this.confirmLoading = false
  190. this.form.resetFields()
  191. if (this.BaseTool.Object.isNotBlank(values)) {
  192. this.$emit('ok', values)
  193. }
  194. }
  195. }
  196. }
  197. </script>