node-edit-final-check.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div>
  3. <el-form :model="form" ref="form" :rules="rules" label-width="100px">
  4. <el-row>
  5. <el-col :span="8">
  6. <el-form-item label="工时单价">
  7. <el-input v-model="form.quotedPrice" placeholder="工时单价"></el-input>
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="8">
  11. <el-form-item label="工序要求" prop="require">
  12. <el-input v-model="form.require" :disabled="disabled || selectOperator"></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="8">
  16. <el-form-item label="所需工时" prop="preTaskTime" v-if="node.type !== 'end'">
  17. <el-input v-model="form.preTaskTime" :disabled="disabled || selectOperator"
  18. oninput="value=value.replace(/[^0-9.]/g,'')">
  19. <i slot="suffix" style="font-style: normal; margin-right: 10px">h</i>
  20. </el-input>
  21. </el-form-item>
  22. </el-col>
  23. </el-row>
  24. <el-row>
  25. <el-col :span="8">
  26. <el-form-item label="操作人" v-if="form.operatorName && !selectOperator">
  27. <el-input :disabled="disabled && selectOperator" v-model="form.operatorName"></el-input>
  28. </el-form-item>
  29. <el-form-item label="操作人" prop="operatorId" v-if="selectOperator">
  30. <el-select v-model="form.operatorId" :disabled="disabled && selectOperator || !isEdit" multiple
  31. placeholder="请选择" style="width: 100%">
  32. <el-option v-for="item in operatorIdOptions" :key="item.userId" :label="item.name"
  33. :value="item.userId"></el-option>
  34. </el-select>
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. <el-row>
  39. <el-col :span="24">
  40. <el-form-item label="备注" prop="notes">
  41. <el-input type="textarea" v-model="form.notes" :disabled="disabled || selectOperator"></el-input>
  42. </el-form-item>
  43. </el-col>
  44. </el-row>
  45. <el-row>
  46. <el-col :span="24">
  47. <div>检验项目</div>
  48. </el-col>
  49. </el-row>
  50. <!-- <el-row>
  51. <el-col :span="24">
  52. <el-form-item label="检验方法">
  53. <div>
  54. 1.游标卡尺,2.千分尺,3.高度尺,4.百分表,5.R规,6.环规、塞规,7.游标角度尺,8.三坐标,9.模具,10.样板,11.夹具,12.目测,13.组合测量,14.精密测量,15.敲击,16.测厚仪,17.其他
  55. </div>
  56. </el-form-item>
  57. </el-col>
  58. </el-row> -->
  59. <el-row>
  60. <el-table :data="form.prodProductionRequireList" style="width: 100%">
  61. <el-table-column prop="pageNo" label="页次/图区">
  62. <template slot-scope="scope">
  63. <el-form-item :prop="'prodProductionRequireList.' + scope.$index + '.pageNo'" :rules="rules.pageNo"
  64. label-width="0px">
  65. <el-input v-model="scope.row.pageNo" :disabled="disabled || selectOperator || isEdit"></el-input>
  66. </el-form-item>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="inspectionParam" label="检查参数">
  70. <template slot-scope="scope">
  71. <el-form-item :prop="'prodProductionRequireList.' +
  72. scope.$index +
  73. '.inspectionParam'
  74. " :rules="rules.inspectionParam" label-width="0px">
  75. <el-input v-model="scope.row.inspectionParam" :disabled="disabled || selectOperator || isEdit"
  76. @blur="inspectionParamBlur($event, scope.$index)"></el-input>
  77. </el-form-item>
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="inspectionMethod" label="检验方法">
  81. <template slot-scope="scope">
  82. <el-form-item :prop="'prodProductionRequireList.' +
  83. scope.$index +
  84. '.inspectionMethod'
  85. " :rules="rules.inspectionMethod" label-width="0px">
  86. <el-select v-model="scope.row.inspectionMethod" placeholder="请选择" style="width: 100%"
  87. :disabled="disabled || selectOperator || isEdit">
  88. <el-option v-for="item in inspectionMethodOptions" :key="item.value" :label="item.name"
  89. :value="item.value"></el-option>
  90. </el-select>
  91. </el-form-item>
  92. </template>
  93. </el-table-column>
  94. <el-table-column prop="allowValues" label="允许值">
  95. <template slot-scope="scope">
  96. <el-form-item :prop="'prodProductionRequireList.' + scope.$index + '.allowValues'
  97. " :rules="rules.allowValues" label-width="0px">
  98. <el-input v-model="scope.row.allowValues" :disabled="disabled || selectOperator || isEdit"></el-input>
  99. </el-form-item>
  100. </template>
  101. </el-table-column>
  102. <el-table-column prop="measureRecord1" label="实测记录1">
  103. <template slot-scope="scope">
  104. <div style="margin-bottom:22px;">{{ scope.row.measureRecord1 }}</div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="measureRecord2" label="实测纪录2">
  108. <template slot-scope="scope">
  109. <div style="margin-bottom:22px;">{{ scope.row.measureRecord2 }}</div>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="操作" width="140px" v-if="!disabled && !isEdit">
  113. <template slot-scope="scope">
  114. <el-button type="primary" icon="el-icon-circle-plus" circle @click="addRow"></el-button>
  115. <el-button type="danger" icon="el-icon-delete" circle @click="removeRow(scope.$index)"
  116. v-if="scope.$index > 0"></el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. </el-row>
  121. <el-form-item label="附件" prop="attachList" v-if="!disabled && !selectOperator">
  122. <upload-component :accept="'*'" v-model="form.attachList" :file-obj-list="form.attachList" />
  123. </el-form-item>
  124. <el-form-item v-else prop="attachList">
  125. <upload-component :display="true" :accept="'*'" v-model="form.attachList" />
  126. </el-form-item>
  127. </el-form>
  128. </div>
  129. </template>
  130. <script>
  131. import { getWorkType } from '@/api/crafts'
  132. import { workTypeMasterList } from '@/api/worktype'
  133. import UploadComponent from '@/views/modules/common/upload-component-v2'
  134. import NodeEditNormal from '@/components/work-flow/node-edit-normal.vue'
  135. export default {
  136. name: 'nodeEdit',
  137. components: { UploadComponent, NodeEditNormal },
  138. props: {
  139. data: {
  140. type: Object,
  141. default: () => { }
  142. },
  143. disabled: {
  144. type: Boolean,
  145. default: false
  146. },
  147. // 是否选择操作人,当选择操作人时,其他字段不可编辑
  148. selectOperator: {
  149. type: Boolean,
  150. default: false
  151. },
  152. isEdit: {
  153. type: Boolean,
  154. default: false
  155. }
  156. },
  157. data() {
  158. return {
  159. // 工种列表
  160. workTypeOptions: [],
  161. // 操作人列表
  162. operatorIdOptions: [],
  163. node: {},
  164. form: {
  165. nodeName: '',
  166. workTypeId: '',
  167. operatorId: [],
  168. prodProductionRequireList: [{}],
  169. planCompletionTime: ''
  170. },
  171. fileList: [],
  172. inspectionMethodOptions: [
  173. { value: '1', name: '游标卡尺' },
  174. { value: '2', name: '千分尺' },
  175. { value: '3', name: '高度尺' },
  176. { value: '4', name: '百分表' },
  177. { value: '5', name: 'R规' },
  178. { value: '6', name: '环规、塞规' },
  179. { value: '7', name: '游标角度尺' },
  180. { value: '8', name: '三坐标' },
  181. { value: '9', name: '模具' },
  182. { value: '10', name: '样板' },
  183. { value: '11', name: '夹具' },
  184. { value: '12', name: '目测' },
  185. { value: '13', name: '组合测量' },
  186. { value: '14', name: '精密测量' },
  187. { value: '15', name: '敲击' },
  188. { value: '16', name: '测厚仪' },
  189. { value: '17', name: '其他' }
  190. ],
  191. rules: {
  192. // attachList: [
  193. // { required: true, message: '请上传附件', trigger: 'change' }
  194. // ],
  195. nodeName: [
  196. { required: true, message: '请输入节点名称', trigger: 'blur' }
  197. ],
  198. workTypeId: [
  199. { required: true, message: '请选择工种', trigger: 'blur' }
  200. ],
  201. operatorId: [
  202. { required: true, message: '请选择操作人', trigger: 'blur' }
  203. ],
  204. preTaskTime: [
  205. { required: true, message: '请输入所需工时', trigger: 'blur' }
  206. ],
  207. pageNo: [{ required: true, message: '请输入', trigger: 'blur' }],
  208. inspectionParam: [
  209. { required: true, message: '请输入', trigger: 'blur' }
  210. ],
  211. inspectionMethod: [
  212. { required: true, message: '请选择', trigger: 'blur' }
  213. ],
  214. allowValues: [{ required: true, message: '请输入', trigger: 'blur' }]
  215. }
  216. }
  217. },
  218. watch: {
  219. data(val) {
  220. this.node = val
  221. this.form = {
  222. ...this.form,
  223. ...this.node
  224. }
  225. if (this.node.operatorId) {
  226. this.form.operatorId = this.node.operatorId.split(',')
  227. }
  228. // 附件
  229. // if (this.node.attachList) {
  230. // this.$nextTick(() => {
  231. // this.fileList = []
  232. // this.node.attachList.forEach((item) => {
  233. // this.fileList.push({
  234. // name: item.fileName,
  235. // url: item.url,
  236. // id: item.url
  237. // })
  238. // })
  239. // })
  240. // }
  241. },
  242. disabled(val) {
  243. this.disabled = val
  244. },
  245. isEdit(val) {
  246. this.isEdit = val
  247. }
  248. },
  249. activated() { },
  250. created() {
  251. this.getWorkTypeOptions()
  252. },
  253. computed: {},
  254. mounted() {
  255. this.node = this.data
  256. this.form = {
  257. ...this.form,
  258. ...this.node
  259. }
  260. if (this.node.operatorId) {
  261. this.form.operatorId = this.node.operatorId.split(',')
  262. }
  263. // 附件
  264. // if (this.node.attachList) {
  265. // this.fileList = []
  266. // this.node.attachList.forEach((item) => {
  267. // this.fileList.push({
  268. // name: item.fileName,
  269. // url: item.url,
  270. // id: item.url
  271. // })
  272. // })
  273. // }
  274. this.getOperatorList()
  275. },
  276. methods: {
  277. getWorkTypeOptions() {
  278. this.workTypeOptions = []
  279. getWorkType().then(({ data }) => {
  280. if (data && data.code === '200') {
  281. this.workTypeOptions = data.data
  282. }
  283. })
  284. },
  285. onChage(val) {
  286. this.workTypeOptions.forEach((v) => {
  287. if (v.typeId === val) {
  288. this.form.quotedPrice = Number(v.quotedPrice || 0).toFixed(2)
  289. }
  290. })
  291. },
  292. // 按工种ID查询操作人列表
  293. getOperatorList() {
  294. if (this.node.workTypeId) {
  295. workTypeMasterList(this.node.workTypeId).then(({ data }) => {
  296. if (data && data.code === '200') {
  297. this.operatorIdOptions = []
  298. data.data.forEach((item) => {
  299. this.operatorIdOptions.push(item)
  300. })
  301. this.onChage(this.node.workTypeId)
  302. }
  303. })
  304. }
  305. },
  306. // 校验表单
  307. validateFormData() {
  308. return new Promise((resolve, reject) => {
  309. this.$refs['form'].validate((valid) => {
  310. if (!valid) {
  311. // eslint-disable-next-line prefer-promise-reject-errors
  312. reject()
  313. return
  314. }
  315. resolve()
  316. })
  317. })
  318. },
  319. // 获取表单数据
  320. formData() {
  321. const form = { ...this.form, operatorName: '' }
  322. form.attachList = []
  323. if (this.form.operatorId != null) {
  324. form.operatorId = this.form.operatorId.toString()
  325. this.form.operatorId.forEach((id) => {
  326. let op = this.operatorIdOptions.find((t) => t.userId === id)
  327. if (op.name != null) {
  328. form.operatorName += op.name + ' '
  329. }
  330. })
  331. }
  332. // 填充附件
  333. // let fList = this.fileList
  334. // if (fList.length > 0) {
  335. // form.attachList = []
  336. // for (let i = 0; i < fList.length; i++) {
  337. // form.attachList.push({
  338. // fileName: fList[i].name,
  339. // url: fList[i].url
  340. // })
  341. // }
  342. // }
  343. return form
  344. },
  345. addRow() {
  346. this.form.prodProductionRequireList.push({})
  347. },
  348. removeRow(index) {
  349. this.form.prodProductionRequireList.splice(index, 1)
  350. },
  351. inspectionParamBlur(event, index) {
  352. console.log(event)
  353. console.log(event.target.value)
  354. this.$http({
  355. url: this.$http.adornUrl(`/biz-service/technology/infoArgument/${event.target.value}`),
  356. method: 'get'
  357. }).then(({ data }) => {
  358. console.log(data)
  359. this.form.prodProductionRequireList[index].allowValues = data
  360. console.log(this.form.prodProductionRequireList)
  361. })
  362. }
  363. }
  364. }
  365. </script>
  366. <style scoped></style>