BaseForm.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <a-card :bordered="false" :title="modalTitle" v-show="visible">
  3. <a-row :gutter="48" slot="extra">
  4. <a-col :md="48" :sm="48">
  5. <span class="table-page-search-submitButtons" style="float: right" >
  6. <a-button style="margin-left: 8px" type="primary" @click="finish()">完成</a-button>
  7. <a-button style="margin-left: 8px" type="primary" @click="save()">保存</a-button>
  8. <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  9. </span>
  10. </a-col>
  11. </a-row>
  12. <title-divider title="基本信息" width="90px"></title-divider>
  13. <a-form :form="form">
  14. <a-form-item v-show="false" >
  15. <a-input v-decorator="['id']" type="hidden"/>
  16. <a-input v-decorator="['sbId']" type="hidden"/>
  17. <a-input v-decorator="['repairId']" type="hidden"/>
  18. </a-form-item>
  19. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  20. <a-col :lg="12" :md="24" :sm="24">
  21. <a-form-item
  22. label="编号"
  23. :labelCol="BaseTool.Constant.labelCol"
  24. :wrapperCol="BaseTool.Constant.wrapperCol">
  25. <a-input
  26. disabled="disabled"
  27. v-decorator="['no']"
  28. />
  29. </a-form-item>
  30. </a-col>
  31. </a-row>
  32. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  33. <a-col :lg="12" :md="24" :sm="24">
  34. <a-form-item
  35. label="分析时间"
  36. :labelCol="BaseTool.Constant.labelCol"
  37. :wrapperCol="BaseTool.Constant.wrapperCol"
  38. >
  39. <a-date-picker
  40. style="width: 100%"
  41. v-decorator="['analyzeTime', {rules: [{required: true, message: '分析时间不能为空'}]}]"
  42. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN" />
  43. </a-form-item>
  44. </a-col>
  45. </a-row>
  46. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  47. <a-col :lg="24" :md="24" :sm="24">
  48. <a-form-item
  49. label="故障现象"
  50. :labelCol="BaseTool.Constant.labelCol2"
  51. :wrapperCol="BaseTool.Constant.wrapperCol2">
  52. <a-textarea
  53. :auto-size="{ minRows: 5 }"
  54. v-decorator="['problemDesc', {rules: [{required: true, message: '分析时间不能为空'}]}]"
  55. />
  56. </a-form-item>
  57. </a-col>
  58. </a-row>
  59. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  60. <a-col :lg="24" :md="24" :sm="24">
  61. <a-form-item
  62. :labelCol="BaseTool.Constant.labelCol2"
  63. :wrapperCol="BaseTool.Constant.wrapperCol2"
  64. label="检查处理过程"
  65. >
  66. <a-textarea
  67. :auto-size="{ minRows: 5 }"
  68. v-decorator="['checkProcess', {rules: [{required: true, message: '检查处理过程不能为空'}]}]"/>
  69. </a-form-item>
  70. </a-col>
  71. </a-row>
  72. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  73. <a-col :lg="24" :md="24" :sm="24">
  74. <a-form-item
  75. :labelCol="BaseTool.Constant.labelCol2"
  76. :wrapperCol="BaseTool.Constant.wrapperCol2"
  77. label="原因分析">
  78. <a-textarea
  79. :auto-size="{ minRows: 5 }"
  80. v-decorator="['reasonAnalysis', {rules: [{required: true, message: '原因分析不能为空'}]}]" />
  81. </a-form-item>
  82. </a-col>
  83. </a-row>
  84. <title-divider title="改进措施" width="90px"></title-divider>
  85. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  86. <a-col :lg="12" :md="24" :sm="24">
  87. <a-form-item
  88. label="更新维修计划"
  89. :labelCol="BaseTool.Constant.labelCol"
  90. :wrapperCol="BaseTool.Constant.wrapperCol">
  91. <a-checkbox :checked="changeRepairPlan" v-model="changeRepairPlan"></a-checkbox>
  92. </a-form-item>
  93. </a-col>
  94. </a-row>
  95. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  96. <a-col :lg="24" :md="24" :sm="24">
  97. <a-form-item
  98. label="内容"
  99. v-show="changeRepairPlan"
  100. :labelCol="BaseTool.Constant.labelCol2"
  101. :wrapperCol="BaseTool.Constant.wrapperCol2"
  102. >
  103. <a-textarea
  104. :auto-size="{ minRows: 5 }"
  105. v-decorator="['changeRepairPlanContent']" />
  106. </a-form-item>
  107. </a-col>
  108. </a-row>
  109. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  110. <a-col :lg="12" :md="24" :sm="24">
  111. <a-form-item
  112. label="更新备件计划"
  113. :labelCol="BaseTool.Constant.labelCol"
  114. :wrapperCol="BaseTool.Constant.wrapperCol">
  115. <a-checkbox :checked="changeSparePlan" v-model="changeSparePlan"></a-checkbox>
  116. </a-form-item>
  117. </a-col>
  118. </a-row>
  119. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  120. <a-col :lg="24" :md="24" :sm="24">
  121. <a-form-item
  122. label="内容"
  123. v-show="changeSparePlan"
  124. :labelCol="BaseTool.Constant.labelCol2"
  125. :wrapperCol="BaseTool.Constant.wrapperCol2"
  126. >
  127. <a-textarea
  128. :auto-size="{ minRows: 5 }"
  129. v-decorator="['changeSparePlanContent']" />
  130. </a-form-item>
  131. </a-col>
  132. </a-row>
  133. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  134. <a-col :lg="12" :md="24" :sm="24">
  135. <a-form-item
  136. label="人员培训"
  137. :labelCol="BaseTool.Constant.labelCol"
  138. :wrapperCol="BaseTool.Constant.wrapperCol">
  139. <a-checkbox :checked="userTeach" v-model="userTeach"></a-checkbox>
  140. </a-form-item>
  141. </a-col>
  142. </a-row>
  143. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  144. <a-col :lg="24" :md="24" :sm="24">
  145. <a-form-item
  146. label="内容"
  147. v-show="userTeach"
  148. :labelCol="BaseTool.Constant.labelCol2"
  149. :wrapperCol="BaseTool.Constant.wrapperCol2"
  150. >
  151. <a-textarea
  152. :auto-size="{ minRows: 5 }"
  153. v-decorator="['userTeachContent']" />
  154. </a-form-item>
  155. </a-col>
  156. </a-row>
  157. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  158. <a-col :lg="12" :md="24" :sm="24">
  159. <a-form-item
  160. label="设备改造升级"
  161. :labelCol="BaseTool.Constant.labelCol"
  162. :wrapperCol="BaseTool.Constant.wrapperCol">
  163. <a-checkbox :checked="sbChange" v-model="sbChange"></a-checkbox>
  164. </a-form-item>
  165. </a-col>
  166. </a-row>
  167. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  168. <a-col :lg="24" :md="24" :sm="24">
  169. <a-form-item
  170. label="内容"
  171. v-show="sbChange"
  172. :labelCol="BaseTool.Constant.labelCol2"
  173. :wrapperCol="BaseTool.Constant.wrapperCol2"
  174. >
  175. <a-textarea
  176. :auto-size="{ minRows: 5 }"
  177. v-decorator="['sbChangeContent']" />
  178. </a-form-item>
  179. </a-col>
  180. </a-row>
  181. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  182. <a-col :lg="12" :md="24" :sm="24">
  183. <a-form-item
  184. label="其他"
  185. :labelCol="BaseTool.Constant.labelCol"
  186. :wrapperCol="BaseTool.Constant.wrapperCol">
  187. <a-checkbox :checked="otherChange" v-model="otherChange"></a-checkbox>
  188. </a-form-item>
  189. </a-col>
  190. </a-row>
  191. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  192. <a-col :lg="24" :md="24" :sm="24">
  193. <a-form-item
  194. label="内容"
  195. v-show="otherChange"
  196. :labelCol="BaseTool.Constant.labelCol2"
  197. :wrapperCol="BaseTool.Constant.wrapperCol2"
  198. >
  199. <a-textarea
  200. :auto-size="{ minRows: 5 }"
  201. v-decorator="['otherChangeContent']" />
  202. </a-form-item>
  203. </a-col>
  204. </a-row>
  205. </a-form>
  206. </a-card>
  207. </template>
  208. <script>
  209. import { addRepairReason, updateRepairReason, finishRepairReason} from '@/api/repair/repair-reason'
  210. import pick from 'lodash.pick'
  211. export default {
  212. name: 'BaseRepairReason',
  213. data () {
  214. return {
  215. confirmLoading: false,
  216. modalTitle: null,
  217. currentTab: 0,
  218. changeRepairPlan: false,
  219. changeSparePlan: false,
  220. userTeach: false,
  221. sbChange: false,
  222. otherChange: false,
  223. addFlag: false,
  224. statusMap: {},
  225. form: this.$form.createForm(this),
  226. visible: false
  227. // 下拉框map
  228. }
  229. },
  230. props: {},
  231. created () {
  232. // 下拉框map
  233. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_REASON_STATUS)
  234. },
  235. methods: {
  236. base (record, repairForm = {}) {
  237. this.visible = true
  238. this.currentTab = 0
  239. const { form: { setFieldsValue } } = this
  240. // 如果是空标识添加
  241. if (this.BaseTool.Object.isBlank(record)) {
  242. this.addFlag = true
  243. this.modalTitle = '添加'
  244. repairForm.repairId = repairForm.id
  245. this.$nextTick(() => {
  246. setFieldsValue(Object.assign(pick(repairForm, [
  247. 'repairId',
  248. 'sbId',
  249. 'no'
  250. ])))
  251. })
  252. return
  253. }
  254. this.addFlag = false
  255. record.analyzeTime = this.BaseTool.Moment(record.analyzeTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  256. this.changeRepairPlan = record.changeRepairPlan
  257. this.changeSparePlan = record.changeSparePlan
  258. this.userTeach = record.userTeach
  259. this.sbChange = record.sbChange
  260. this.otherChange = record.otherChange
  261. this.modalTitle = '编辑'
  262. // 日期处理
  263. this.$nextTick(() => {
  264. setFieldsValue(Object.assign(pick(record, [
  265. 'id',
  266. 'sbId',
  267. 'repairId',
  268. 'no',
  269. 'analyzeTime',
  270. 'problemDesc',
  271. 'checkProcess',
  272. 'reasonAnalysis',
  273. 'improveMeasure',
  274. 'changeRepairPlan: null',
  275. 'changeRepairPlanContent',
  276. 'changeSparePlan',
  277. 'changeSparePlanContent',
  278. 'userTeach',
  279. 'userTeachContent',
  280. 'sbChange',
  281. 'sbChangeContent',
  282. 'otherChange',
  283. 'otherChangeContent',
  284. 'status'
  285. ])))
  286. })
  287. },
  288. next () {
  289. this.currentTab += 1
  290. },
  291. prev () {
  292. this.currentTab -= 1
  293. },
  294. save () {
  295. const { form: { validateFieldsAndScroll } } = this
  296. this.confirmLoading = true
  297. validateFieldsAndScroll((errors, values) => {
  298. if (errors) {
  299. this.confirmLoading = false
  300. return
  301. }
  302. // 日期处理
  303. values.changeRepairPlan = this.changeRepairPlan
  304. values.changeSparePlan = this.changeSparePlan
  305. values.userTeach = this.userTeach
  306. values.sbChange = this.sbChange
  307. values.otherChange = this.otherChange
  308. values.analyzeTime = this.BaseTool.Date.formatter(values.analyzeTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  309. if (this.addFlag) {
  310. addRepairReason(values)
  311. .then((res) => {
  312. this.confirmLoading = false
  313. this.handleCancel()
  314. }).catch(() => {
  315. this.confirmLoading = false
  316. })
  317. } else {
  318. updateRepairReason(values)
  319. .then(() => {
  320. this.handleCancel()
  321. }).catch(() => {
  322. this.confirmLoading = false
  323. })
  324. }
  325. })
  326. },
  327. finish(){
  328. const { form: { validateFieldsAndScroll } } = this
  329. this.confirmLoading = true
  330. validateFieldsAndScroll((errors, values) => {
  331. if (errors) {
  332. this.confirmLoading = false
  333. return
  334. }
  335. // 日期处理
  336. values.changeRepairPlan = this.changeRepairPlan
  337. values.changeSparePlan = this.changeSparePlan
  338. values.userTeach = this.userTeach
  339. values.sbChange = this.sbChange
  340. values.otherChange = this.otherChange
  341. values.analyzeTime = this.BaseTool.Date.formatter(values.analyzeTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  342. finishRepairReason(values)
  343. .then((res) => {
  344. this.confirmLoading = false
  345. this.handleCancel()
  346. }).catch(() => {
  347. this.confirmLoading = false
  348. })
  349. })
  350. },
  351. handleCancel (values) {
  352. this.visible = false
  353. this.confirmLoading = false
  354. this.form.resetFields()
  355. this.$emit('ok', values)
  356. }
  357. }
  358. }
  359. </script>
  360. <style>
  361. .ant-steps-item-process .ant-steps-item-icon>.ant-steps-icon {
  362. color: #fff !important;
  363. }
  364. </style>