PlanCheckForm.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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-input v-decorator="['category']" type="hidden"/>
  14. </a-form-item>
  15. <row-list :col="2" v-if="type!==20">
  16. <row-item>
  17. <a-form-item
  18. label="审核"
  19. :labelCol="BaseTool.Constant.labelCol"
  20. :wrapperCol="BaseTool.Constant.wrapperCol"
  21. >
  22. <a-select v-model="check" >
  23. <a-select-option :value="1">
  24. 通过
  25. </a-select-option>
  26. <a-select-option :value="0">
  27. 拒绝
  28. </a-select-option>
  29. </a-select>
  30. </a-form-item>
  31. </row-item>
  32. </row-list>
  33. <row-list v-if="(this.type === 17 && this.check === 1) || this.type === 20" :col="2">
  34. <row-item >
  35. <a-form-item
  36. label="生产审核人"
  37. :labelCol="BaseTool.Constant.labelCol"
  38. :wrapperCol="BaseTool.Constant.wrapperCol"
  39. >
  40. <a-select
  41. v-decorator="['produceVerifyUserId', {rules: [{required: true, message: '生产审核人不能为空'}]}]"
  42. placeholder="请选择">
  43. <a-select-option
  44. v-for="item in userMap"
  45. :key="item.userId"
  46. :label="item.realName"
  47. :value="item.userId">{{ item.realName }}
  48. </a-select-option>
  49. </a-select>
  50. </a-form-item>
  51. </row-item>
  52. </row-list>
  53. <row-list :col="1">
  54. <row-item>
  55. <a-form-item
  56. label="备注"
  57. :labelCol="BaseTool.Constant.labelCol2"
  58. :wrapperCol="BaseTool.Constant.wrapperCol2"
  59. >
  60. <a-textarea
  61. :rows="4"
  62. v-decorator="['remark']"/>
  63. </a-form-item>
  64. </row-item>
  65. </row-list></a-form>
  66. <template slot="footer">
  67. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  68. </template>
  69. </a-modal>
  70. </template>
  71. <script>
  72. import pick from 'lodash.pick'
  73. import {
  74. approve,
  75. returnRepair,
  76. verifyPassRepair,
  77. verifyRefusedRepair,
  78. verifyProduceRefusedRepair,
  79. verifyProduceRepair,
  80. applyVerifyRepair,
  81. getProducerUser
  82. } from '@/api/repair/application-form'
  83. export default {
  84. name: 'BaseRepairApplicationForm',
  85. data () {
  86. return {
  87. confirmLoading: false,
  88. modalTitle: '审核',
  89. form: this.$form.createForm(this),
  90. visible: false,
  91. check: 1,
  92. type: null,
  93. // 下拉框map
  94. model: null,
  95. userMap: []
  96. }
  97. },
  98. components: {
  99. },
  100. props: {
  101. },
  102. created () {
  103. // 下拉框map
  104. },
  105. methods: {
  106. base (record, type) {
  107. this.visible = true
  108. this.model = record
  109. this.type = type
  110. this.getUser()
  111. const { form: { setFieldsValue } } = this
  112. // 日期处理
  113. this.$nextTick(() => {
  114. setFieldsValue(Object.assign(pick(record, [
  115. 'id',
  116. 'category'
  117. ])))
  118. })
  119. },
  120. getUser () {
  121. getProducerUser().then(res => {
  122. this.userMap = res.data
  123. })
  124. },
  125. save () {
  126. const { form: { validateFieldsAndScroll } } = this
  127. this.confirmLoading = true
  128. validateFieldsAndScroll((errors, values) => {
  129. if (errors) {
  130. this.confirmLoading = false
  131. return
  132. }
  133. switch (true) {
  134. case this.type === 15 && this.check === 1:
  135. approve(values).then(res => {
  136. this.$message.success(res.message)
  137. this.handleCancel()
  138. })
  139. break
  140. case this.type === 15 && this.check === 0:
  141. returnRepair(values).then(res => {
  142. this.$message.success(res.message)
  143. this.handleCancel()
  144. })
  145. break
  146. case this.type === 17 && this.check === 1:
  147. verifyPassRepair(values).then(res => {
  148. this.$message.success(res.message)
  149. this.handleCancel()
  150. })
  151. break
  152. case this.type === 17 && this.check === 0:
  153. verifyRefusedRepair(values).then(res => {
  154. this.$message.success(res.message)
  155. this.handleCancel()
  156. })
  157. break
  158. case this.type === 19 && this.check === 1:
  159. verifyProduceRepair(values).then(res => {
  160. this.$message.success(res.message)
  161. this.handleCancel()
  162. })
  163. break
  164. case this.type === 19 && this.check === 0:
  165. verifyProduceRefusedRepair(values).then(res => {
  166. this.$message.success(res.message)
  167. this.handleCancel()
  168. })
  169. break
  170. case this.type === 20:
  171. applyVerifyRepair(values).then(res => {
  172. this.$message.success(res.message)
  173. this.handleCancel()
  174. })
  175. break
  176. }
  177. })
  178. },
  179. handleCancel () {
  180. this.visible = false
  181. this.check = 1
  182. this.type = null
  183. this.confirmLoading = false
  184. this.form.resetFields()
  185. this.$emit('ok')
  186. }
  187. }
  188. }
  189. </script>