FinishForm.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <a-modal :title="modalTitle" :width="1300" :visible="visible" :confirmLoading="confirmLoading" class="ant-modal2"
  3. @cancel="handleCancel">
  4. <title-divider title="检查项目" width="90px"></title-divider>
  5. <a-table size="small" :data-source="requirementList" :columns="columns" bordered tableLayout="auto" rowKey="id"
  6. :pagination="false">
  7. <template #value="text, record">
  8. <a-input size="small" v-if="record.type == 0" v-model="record.value" />
  9. <a-select size="small" v-else v-model="record.value" style="width: 100%">
  10. <a-select-option v-for="option in record.options" :key="option" :label="option" :value="option">{{ option
  11. }}</a-select-option>
  12. </a-select>
  13. </template>
  14. <template #text="text, record">
  15. <a-input size="small" v-model="record.text" />
  16. </template>
  17. </a-table>
  18. <br>
  19. <a-form :form="form">
  20. <a-form-item v-show="false">
  21. <a-input v-decorator="['id']" type="hidden" />
  22. </a-form-item>
  23. <a-form-item v-show="false">
  24. <a-input v-decorator="['actualStartTime']" type="hidden" />
  25. </a-form-item>
  26. <a-form-item label="标准id" v-show="false">
  27. <a-input v-decorator="['standardId', { rules: [{ required: true, message: '标准id不能为空' }] }]" />
  28. </a-form-item>
  29. <row-list :col="2">
  30. <row-item>
  31. <a-form-item label="完成图片" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
  32. <UploadImg :maxSize="20" v-decorator="['imgList']" />
  33. </a-form-item>
  34. </row-item>
  35. <row-item>
  36. <a-form-item label="附件" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
  37. <UploadFile v-decorator="['fileList']" />
  38. </a-form-item>
  39. </row-item>
  40. <row-item>
  41. </row-item>
  42. </row-list>
  43. <a-form-item label="检查结果" :labelCol="BaseTool.Constant.labelCol2" :wrapperCol="BaseTool.Constant.wrapperCol2">
  44. <a-textarea :rows="4" v-decorator="['feedback']" />
  45. </a-form-item>
  46. </a-form>
  47. <template slot="footer">
  48. <a-button :loading="confirmLoading" type="primary" @click="save()">完成</a-button>
  49. <a-button :loading="confirmLoading" type="danger" @click="save(1)">完成并报修</a-button>
  50. </template>
  51. <base-form ref="baseModal" @ok="handleOk" />
  52. </a-modal>
  53. </template>
  54. <script>
  55. import pick from 'lodash.pick'
  56. import { addCheckJob, finishJob } from '@/api/check/checkjob'
  57. import UploadFile from '@/components/Upload/CUploadFile.vue'
  58. import UploadImg from '@/components/Upload/CUploadImg.vue'
  59. import BaseForm from '@/views/repair/application-form/modules/BaseForm'
  60. import { fetchSbInfo } from '@/api/sb/info'
  61. import { fetchCheckStandard } from '@/api/check/checkstandard'
  62. export default {
  63. name: 'BaseCheckJob',
  64. components: {
  65. BaseForm,
  66. UploadFile,
  67. UploadImg,
  68. },
  69. data() {
  70. return {
  71. confirmLoading: false,
  72. modalTitle: null,
  73. form: this.$form.createForm(this),
  74. visible: false,
  75. // 下拉框map
  76. sbId: null,
  77. modelStandard: {},
  78. requirementList: [],
  79. columns: [
  80. // {
  81. // title: '序号',
  82. // dataIndex: 'index',
  83. // customRender: (text, record, index) => {
  84. // return `${index + 1}`
  85. // },
  86. // },
  87. {
  88. title: '保养周期',
  89. dataIndex: 'period'
  90. },
  91. {
  92. title: '管理项目',
  93. dataIndex: 'manageItem',
  94. },
  95. {
  96. title: '检查项目',
  97. dataIndex: 'checkItem',
  98. },
  99. {
  100. title: '方法工具',
  101. dataIndex: 'method',
  102. },
  103. {
  104. title: '保养级别',
  105. dataIndex: 'checkLevel',
  106. },
  107. {
  108. title: '标准类型',
  109. dataIndex: 'sbTypeName',
  110. },
  111. {
  112. title: '内容',
  113. dataIndex: 'remark',
  114. },
  115. {
  116. title: '填报信息',
  117. dataIndex: 'value',
  118. width: '10%',
  119. scopedSlots: { customRender: 'value' },
  120. },
  121. {
  122. title: '备注',
  123. width: '10%',
  124. dataIndex: 'text',
  125. scopedSlots: { customRender: 'text' },
  126. },
  127. ],
  128. }
  129. },
  130. props: {
  131. /**
  132. * 检查类型: 1-负责 2-巡检
  133. */
  134. checkType: {
  135. type: Number,
  136. default: 1,
  137. },
  138. },
  139. created() {
  140. // 下拉框map
  141. },
  142. methods: {
  143. base(record) {
  144. this.visible = true
  145. fetchCheckStandard({ id: record.standardId }).then((res) => {
  146. this.modelStandard = res.data
  147. this.requirementList =
  148. res.data.requirementList &&
  149. res.data.requirementList.map((item, index) => {
  150. item.options = item.type == '1' && item.scope ? item.scope.split('-') : []
  151. item.value = null
  152. return {
  153. ...item,
  154. }
  155. })
  156. })
  157. // 如果是空标识添加
  158. this.modalTitle = '编辑'
  159. const {
  160. form: { setFieldsValue },
  161. } = this
  162. // 日期处理
  163. this.sbId = record.sbId
  164. this.$nextTick(() => {
  165. setFieldsValue(Object.assign(pick(record, ['id', 'standardId', 'feedback', 'imgList', 'fileList', 'actualStartTime'])))
  166. })
  167. },
  168. save(type) {
  169. const {
  170. form: { validateFieldsAndScroll },
  171. } = this
  172. this.confirmLoading = true
  173. validateFieldsAndScroll((errors, values) => {
  174. if (errors) {
  175. this.confirmLoading = false
  176. return
  177. }
  178. // 日期处理
  179. let isReturn = false
  180. this.requirementList.forEach((item) => {
  181. if (!item.value && item.type == 1) {
  182. isReturn = true
  183. }
  184. })
  185. if (isReturn) {
  186. this.confirmLoading = false
  187. this.$message.error('请填写检查结果')
  188. return
  189. }
  190. values.conTask = JSON.stringify(this.requirementList)
  191. console.log(values, 'values')
  192. finishJob(values)
  193. .then(() => {
  194. if (type === 1) {
  195. this.handleAdd()
  196. } else {
  197. this.handleCancel(values)
  198. }
  199. })
  200. .catch(() => {
  201. this.confirmLoading = false
  202. })
  203. })
  204. },
  205. handleCancel(values) {
  206. this.visible = false
  207. this.confirmLoading = false
  208. this.form.resetFields()
  209. this.$emit('ok', values)
  210. },
  211. handleAdd() {
  212. fetchSbInfo({ id: this.sbId }).then((res) => {
  213. this.visible = false
  214. const modal = this.$refs.baseModal
  215. // 使用位置绑定的是设备位置树 title(positionName),cph 仅在报修回写后才有值,这里优先取 positionName,兜底 cph 兼容老数据
  216. modal.base({ sbId: this.sbId, sbName: res.data.name, sbCph: res.data.positionName || res.data.cph })
  217. })
  218. },
  219. handleOk() {
  220. this.handleCancel()
  221. },
  222. },
  223. }
  224. </script>