halfCheck-add.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  1. <!-- @desc:半检 @auth:寇珊珊 @time:2023年3月7日09:22:05 -->
  2. <template>
  3. <div class="main-div">
  4. <!--加载中-->
  5. <loading :loading="loading" v-if="!modalVisible"></loading>
  6. <DkPaxeButton :total="editKeys?editKeys.length:0"
  7. :current="editIndex"
  8. v-if="editKeys && editKeys.length > 1"
  9. @pageChange="editPageChange"></DkPaxeButton>
  10. <DkCollapse>
  11. <DkPanel prop="essentialInformation">
  12. <!-- 下拉区域 -->
  13. <DkForm slot="content" ref="formInline" v-model="formData" style="width: 95%">
  14. <!--选择工位-->
  15. <DkFormItem v-if="workStationList.length>0 || formData.stationId" :required="true" prop="stationId"
  16. :data-type="$config.dataType.number" :label="$t('stationId')">
  17. <SelectMagnifier v-model="formData.stationId" :display-text="formData.stationName"
  18. :type="this.$config.MagnifierType.station"
  19. :multiple="false"
  20. :disabled="stationFlag"
  21. :other-condition="{flowNodeId:flowNodeId}"
  22. @ok="chooseStation"></SelectMagnifier>
  23. </DkFormItem>
  24. <!--生产工号-->
  25. <DkFormItem :required="true" prop="prodUserCode">
  26. <InputPop ref="prodUserCode" name ="prodUserCode" v-model="formData.prodUserCode"
  27. :readonly="!userKind ||userKind == $config.operationUserType.produceUser"
  28. @on-enter="onEnterBlur" @on-blur="onProdUserCode"/>
  29. </DkFormItem>
  30. <!--产品条码-->
  31. <DkFormItem :required="true" prop="barCode">
  32. <InputPop :readonly="!formData.prodUserId" ref="barCode" v-model="formData.barCode" @on-enter="onBarCode"
  33. @on-blur="onBarCode" @on-clear="clearBarCode"/>
  34. </DkFormItem>
  35. <!--商标-->
  36. <DkFormItem :required="true" prop="logoName">
  37. <InputPop ref="logoName" v-model="formData.logoName" :readonly="true"/>
  38. </DkFormItem>
  39. <!--釉色-->
  40. <DkFormItem :required="true" prop="colourName">
  41. <InputPop ref="colourName" v-model="formData.colourName" :readonly="true"/>
  42. </DkFormItem>
  43. <!--编码-->
  44. <DkFormItem :required="true" prop="productCode">
  45. <InputPop ref="productCode" v-model="formData.productCode" :readonly="true"/>
  46. </DkFormItem>
  47. <!--名称-->
  48. <DkFormItem :required="true" prop="productName">
  49. <InputPop ref="productName" v-model="formData.productName" :readonly="true"/>
  50. </DkFormItem>
  51. <!--产品等级-->
  52. <DkFormItem prop="opnGradeId" :required="true" :label="$t('gradeClassification')" data-type="number">
  53. <SelectPop v-model="formData.opnGradeId" ref="gradeName" :multiple="false"
  54. :options="gradeList"
  55. :disabled="!gradeFlag"
  56. @on-select="chooseGrade"
  57. labelKey="gradeName"
  58. valueKey="gradeId">
  59. </SelectPop>
  60. </DkFormItem>
  61. </DkForm>
  62. </DkPanel>
  63. <div
  64. v-show="formData.barCode && formData.opnGradeKind&& formData.opnGradeKind != $config.gradeKindType.excellent">
  65. <DkPanel prop="chooseDefect">
  66. <!--添加行按钮-->
  67. <DkButton slot="content" type="success" @click="addRow" size="small"
  68. style="float: left;position: relative; bottom: 35px;left: 110px;">{{ $v('saveDetail') }}
  69. </DkButton>
  70. <!--清空-->
  71. <DkButton slot="content" type="primary" @click="clearRow" size="small"
  72. style="float: left;position: relative; bottom: 35px;left: 125px;">{{ $v('clearDefect') }}
  73. </DkButton>
  74. <DkSplit slot="content" v-model="split" :height="tableHeight-500">
  75. <!--缺陷信息-->
  76. <EditTable slot="left" ref="recordTable" :data="detailList"
  77. :columns="detailColumns"
  78. :showSettingFlag="false"
  79. :height="tableHeight-500"
  80. :freeze="false"
  81. :add-flag="false" :delete-flag="false"
  82. @chooseData="chooseData"
  83. @clear-select="clearSelect"
  84. controlId="defectCode"
  85. @changeValue="changeValue"
  86. ></EditTable>
  87. <!--责任员工-->
  88. <DkTable slot="right" ref="staff-table-select" :data="staffList" multiple
  89. :height="tableHeight-500" primaryKey="staffId"
  90. :pageFlag="false"
  91. :pageTotalFlag="false"
  92. :linkClickChecked="true"
  93. name="table">
  94. <DkTableColumn field="staffName" :title="$t('staffName')" width="auto"></DkTableColumn>
  95. </DkTable>
  96. </DkSplit>
  97. </DkPanel>
  98. <!--明细-->
  99. <DkPanel prop="details">
  100. <div slot="content" :style="'height: ' + tableHeight-120 + 'px'">
  101. <!--缺陷信息-->
  102. <EditTable slot="left" ref="submitTable" :data="editDetailList"
  103. :columns="editDetailColumns"
  104. :height="tableHeight-120"
  105. :freeze="false"
  106. :add-flag="false"
  107. @delRow="delSubmitTable"
  108. ></EditTable>
  109. </div>
  110. </DkPanel>
  111. </div>
  112. </DkCollapse>
  113. <!-- 下部分按钮区域-->
  114. <DkSaveButton ref="saveButton" :loading="loading" @save="save" @close="close"></DkSaveButton>
  115. <!--缺陷位置-->
  116. <DkModal
  117. :loading="loading"
  118. v-model="defectPlaceModal"
  119. ref="modal_defectPlace"
  120. @on-visible-change="handleVisibleModal"
  121. @modalOk="saveDefectPlace"
  122. :saveFlag="true"
  123. :title=modalTitle
  124. >
  125. </DkModal>
  126. <!--验证标签-->
  127. <DkModal
  128. :loading="loading"
  129. v-model="labelModal"
  130. ref="modal_label"
  131. @on-visible-change="handleVisibleModal"
  132. @modalOk="saveLabel"
  133. :saveFlag="true"
  134. :title=modalTitle
  135. :maskClosable="false"
  136. >
  137. <DkForm ref="labelFormInline" v-model="labelFormData" :col-count="1">
  138. <DkFormItem required :data-type="$config.dataType.str"
  139. v-for="(item,index) in pdtLabelKinds" :key="index" :label="item.labelName">
  140. <InputPop v-model="item.labelCode" ref="item.labelCode"/>
  141. </DkFormItem>
  142. </DkForm>
  143. </DkModal>
  144. </div>
  145. </template>
  146. <script>
  147. import { formMixin } from '@/mixins/form'
  148. export default {
  149. name: 'halfCheck-add',
  150. mixins: [formMixin],
  151. data() {
  152. let self = this
  153. return {
  154. gradeFlag: null,//改判权限标识
  155. tableData: [],
  156. loading: false,
  157. tableHeight: 620,
  158. // 画面表单数据
  159. formData: {
  160. stationId: null,
  161. stationName: '',
  162. prodUserId: null,
  163. prodUserCode: '',
  164. barCode: '',
  165. ftyId: this.$store.state.user.ftyId,
  166. productId: null,
  167. productCode: '',
  168. productName: '',
  169. logoName: '',
  170. colourName: '',
  171. opnGradeId: null,
  172. gradeName: null,
  173. opnGradeKind: null,
  174. },
  175. defectCode: null,//缺陷编码
  176. modelId: null,//产品型号
  177. flowNodeId: self.$route.meta.menuUuid,
  178. workStationList: [],//工位数据
  179. editItemColumns: ['itemId', 'moldingId', 'productUniqueCode'],
  180. gradeList: [],//产品等级
  181. detailList: [],// 成型记录明细信息
  182. defectFines: [],//缺陷扣罚
  183. defectNodeList: [],//责任工序
  184. staffList: [],//责任员工
  185. dutyUserList: [],//责任人
  186. jobId: null,//责任工种
  187. split: 0.7,//明细左右宽度比
  188. // 明细列表
  189. detailColumns: [
  190. // 缺陷编码
  191. { field: 'defectCode', type: 'text', width: 'auto', controlId: 'defectCode', },
  192. //缺陷名称
  193. { field: 'defectName', type: 'disabled', width: 'auto', },
  194. //缺陷扣罚
  195. {
  196. field: 'dftFineId',
  197. type: 'select',
  198. options: () => self.defectFines,
  199. labelKey: 'fineName',
  200. valueKey: 'fineId',
  201. width: 'auto',
  202. },
  203. // 扣除数
  204. { field: 'deductNum', type: 'disabled', width: 'auto' },
  205. // 缺陷位置
  206. {
  207. field: 'pdtPlaceId',
  208. type: 'select',
  209. options: () => self.defectPlaceList,
  210. labelKey: 'placeName',
  211. valueKey: 'placeId',
  212. width: 'auto'
  213. },
  214. // 责任工序
  215. {
  216. field: 'blameNodeId',
  217. type: 'select',
  218. options: () => self.defectNodeList,
  219. labelKey: 'nodeName',
  220. valueKey: 'nodeId',
  221. width: 'auto'
  222. },
  223. // 责任工号
  224. {
  225. field: 'userName',
  226. title: self.$t('blameUserId'),
  227. width: 'auto',
  228. sortBoolean: false,
  229. multiple: false,
  230. type: 'tableSelect',
  231. param: () => {
  232. return {
  233. nodeId: self.blameNodeId ? parseInt(self.blameNodeId) : null,
  234. productId: self.blameNodeId ? self.formData.productId : null,
  235. }
  236. },
  237. dataType: self.$config.tableSelectType.blameUser,
  238. fieldUpdate: self.$updateColumns.halfCheckUser,
  239. searchDetailFlag: false,
  240. },
  241. // 责任工种
  242. {
  243. field: 'jobName',
  244. title: self.$t('blameWsJobId'),
  245. width: 'auto',
  246. sortBoolean: false,
  247. multiple: false,
  248. type: 'tableSelect',
  249. param: () => {
  250. return {
  251. nodeId: self.blameNodeId ? parseInt(self.blameNodeId) : null,
  252. productId: self.formData.productId,
  253. userId: self.userId ? parseInt(self.userId) : null,
  254. defectId: self.pdtDefectId ? parseInt(self.pdtDefectId) : null,
  255. }
  256. },
  257. dataType: self.$config.tableSelectType.job,
  258. fieldUpdate: self.$updateColumns.halfCheckJob,
  259. searchDetailFlag: false
  260. },
  261. ],
  262. //用来展示的明细列表
  263. editDetailColumns: [
  264. // 缺陷编码
  265. { field: 'pdtDefectCode', title: self.$t('defectCode'), type: 'disabled', width: 'auto', },
  266. //缺陷名称
  267. { field: 'pdtDefectName', title: self.$t('defectName'), type: 'disabled', width: 'auto', },
  268. //缺陷扣罚
  269. { field: 'dftFineName', type: 'disabled', width: 'auto', },
  270. // 扣除数
  271. { field: 'deductNum', type: 'disabled', width: 'auto' },
  272. // 缺陷位置
  273. { field: 'pdtPlaceName', title: self.$t('pdtPlaceId'), type: 'disabled', width: 'auto' },
  274. // 责任工序
  275. { field: 'blameNodeName', title: self.$t('blameNodeId'), type: 'disabled', width: 'auto' },
  276. // 责任工号
  277. { field: 'blameUserName', title: self.$t('blameUserId'), type: 'disabled', width: 'auto' },
  278. // 责任工种
  279. { field: 'blameJobName', title: self.$t('blameWsJobId'), type: 'disabled', width: 'auto' },
  280. //责任员工
  281. { field: 'blameStaffName', title: self.$t('blameStaffId'), type: 'disabled', width: 'auto' },
  282. ],
  283. editDetailList: [],
  284. productionDefectDelIdList: [],//被删除的数据
  285. rowIndex: 0,
  286. userKind: null,//用户类型
  287. defectPlaceModal: false,//缺陷弹窗
  288. modalTitle: self.$config.formMode.setDefectPlace,
  289. defectPlaceList: [],//缺陷位置
  290. stationFlag: false,//默认工位标识
  291. userId: null,//当前选择的工号
  292. blameNodeId: null,//当前选择的工序
  293. pdtDefectId: null,//当前选择的缺陷
  294. labelFlag: false,//默认验证标签
  295. pdtLabelKinds: [],//开的验证标签
  296. checkModelPdtLabelJson: {},//校验验证标签
  297. modelPdtLabelJson: {},//验证标签集合
  298. labelModal: false,//验证标签modal
  299. labelFormData: {},
  300. getBarCodeMessage: null,//产品条码信息
  301. onProdUserCodeFlag: false,//校验打卡标识
  302. }
  303. },
  304. methods: {
  305. //region 失焦查询数据
  306. /**
  307. * @desc : 回车失焦事件
  308. * @date : 2023/4/21 16:00
  309. * @author : 寇珊珊
  310. */
  311. onEnterBlur(){
  312. this.$refs.prodUserCode.$refs.input.blur()
  313. },
  314. /**
  315. * @desc : 生产工号失焦事件
  316. * @date : 2023/2/28 9:28
  317. * @author : 寇珊珊
  318. */
  319. onProdUserCode() {
  320. if (this.onProdUserCodeFlag) {
  321. return
  322. }
  323. this.onProdUserCodeFlag = true
  324. if (this.formData.prodUserCode) {
  325. let params = {
  326. ftyId: this.formData.ftyId,
  327. prodUserCode: this.formData.prodUserCode,
  328. stationId: this.formData.stationId,
  329. flowNodeId: this.flowNodeId,
  330. }
  331. this.excute(this.$service.collectService, this.$service.collectService.checkProdUserCode, params).then(res => {
  332. this.formData.prodUserId=null
  333. if (res.code === this.$config.SUCCESS_CODE) {
  334. this.formData.prodUserId = parseInt(res.data)
  335. }
  336. //没有打卡
  337. else if (res.code !== this.$config.SUCCESS_CODE &&
  338. this.$config.processTypeException.CHKCAR008 == res.exception) {
  339. if (this.$libaray.checkButtonHasRight('ws-clock-user',this)) {
  340. this.$IBMessage({
  341. content: this.$t('Q_013'),
  342. title: this.$t('systemQuestion'),
  343. },
  344. {
  345. ok: () => {
  346. this.onProdUserCodeFlag = false
  347. this.$router.push('/pdm/ws-clock/clock-user')
  348. },
  349. cancel: () => {
  350. this.closeTag(this.$route)
  351. }
  352. })
  353. } else {
  354. this.onProdUserCodeFlag = false
  355. this.$Modal.warning({
  356. title: this.$t('systemInfo'),
  357. content: this.$t('Q_019')
  358. });
  359. }
  360. } else {
  361. this.onProdUserCodeFlag = false
  362. this.$Message.error(res.message)
  363. }
  364. })
  365. } else {
  366. this.onProdUserCodeFlag = false
  367. }
  368. },
  369. /**
  370. * @desc : 产品条码失焦事件
  371. * @date : 2023/2/28 9:28
  372. * @author : 寇珊珊
  373. */
  374. onBarCode() {
  375. if (this.formData.barCode) {
  376. let params = {
  377. ftyId: this.formData.ftyId,
  378. barCode: this.formData.barCode,
  379. prodUserCode: this.formData.prodUserCode,
  380. flowNodeId: this.flowNodeId,
  381. }
  382. this.excute(this.$service.collectService, this.$service.collectService.checkBarCode, params).then(res => {
  383. if (res.code === this.$config.SUCCESS_CODE) {
  384. if (0 == parseInt(res.data.flowNodeNum)) {
  385. this.gradeFlag = true
  386. }
  387. this.getBarCodeMessage = res
  388. //验证标签开启并且工序类型为产品码
  389. if (this.$config.processType.productCode == this.opnKind && this.labelFlag) {
  390. this.modalTitle = this.$t('label') // 给modal标题赋值
  391. this.labelModal = true
  392. } else {
  393. //验证产品条码后赋值
  394. this.setBarCode(this.getBarCodeMessage)
  395. }
  396. } else {
  397. this.$Message.error(res.message)
  398. }
  399. })
  400. }
  401. },
  402. /**
  403. * @desc : 保存验证标签
  404. * @date : 2023/3/29 13:48
  405. * @author : 寇珊珊
  406. */
  407. saveLabel() {
  408. this.$refs['labelFormInline'].validate().then(valid => {
  409. if (valid) {
  410. this.checkModelPdtLabelJson[this.formData.barCode] = this.pdtLabelKinds
  411. let params = {
  412. flowNodeId: this.flowNodeId,
  413. ftyId: this.formData.ftyId,
  414. barCode: this.formData.barCode,
  415. modelPdtLabelList: this.checkModelPdtLabelJson,
  416. }
  417. this.excute(this.$service.collectService, this.$service.collectService.checkLabel, params).then(res => {
  418. if (res.code === this.$config.SUCCESS_CODE) {
  419. this.labelModal = false
  420. this.modelPdtLabelJson[this.formData.barCode] = this.pdtLabelKinds.copy()
  421. for (let i of this.pdtLabelKinds) {
  422. i['labelCode'] = ''
  423. }
  424. //验证产品条码后赋值
  425. this.setBarCode(this.getBarCodeMessage)
  426. } else {
  427. this.$Message.error(res.message)
  428. }
  429. })
  430. }
  431. })
  432. },
  433. /**
  434. * @desc : 验证产品条码后赋值
  435. * @date : 2023/4/4 14:38
  436. * @author : 寇珊珊
  437. */
  438. setBarCode(res) {
  439. this.modelId = res.data.modelId
  440. this.formData.productId = res.data.uniqueId
  441. this.formData.productCode = res.data.modelCode
  442. this.formData.productName = res.data.modelName
  443. this.formData.logoName = res.data.logoName
  444. this.formData.colourName = res.data.colourName
  445. this.formData.opnGradeId = res.data.opnGradeId
  446. this.formData.opnGradeKind = res.data.opnGradeKind
  447. if (res.data.productionDefectList && res.data.productionDefectList.length > 0) {
  448. let list = res.data.productionDefectList
  449. for (let i = 0; i < list.length; i++) {
  450. this.editDetailList = list
  451. }
  452. }
  453. //产品等级不为优
  454. if (this.formData.opnGradeKind != this.$config.gradeKindType.excellent) {
  455. //调用查询缺陷位置
  456. this.getDefectPlace()
  457. } else {
  458. this.defectPlaceList = []
  459. }
  460. },
  461. /**
  462. * @desc : 产品条码清空
  463. * @date : 2023/3/22 13:27
  464. * @author : 寇珊珊
  465. */
  466. clearBarCode() {
  467. this.formData.barCode = null
  468. this.formData.productId = null
  469. this.formData.productCode = null
  470. this.formData.productName = null
  471. this.formData.logoName = null
  472. this.formData.colourName = null
  473. this.formData.opnGradeId = null
  474. this.formData.gradeName = null
  475. this.formData.opnGradeKind = null
  476. },
  477. /**
  478. * @desc : 查询缺陷数据
  479. * @date : 2023/3/9 10:46
  480. * @author : 寇珊珊
  481. */
  482. getDefect(index) {
  483. let params = {
  484. flowNodeId: this.flowNodeId,
  485. ftyId: this.formData.ftyId,
  486. pdtDefectId: this.detailList[index].pdtDefectId,
  487. barCode: this.formData.barCode,
  488. barCodeId: this.formData.productId,
  489. }
  490. this.excute(this.$service.collectService, this.$service.collectService.getBlameNode, params).then(res => {
  491. if (res.code === this.$config.SUCCESS_CODE) {
  492. this.defectNodeList = res.data
  493. if (this.defectNodeList && this.defectNodeList.length == 1) {
  494. //赋值责任相关信息
  495. this.setBlameMessage(this.defectNodeList)
  496. }
  497. } else {
  498. this.$Message.error(res.message)
  499. }
  500. })
  501. },
  502. /**
  503. * @desc : 赋值责任相关信息
  504. * @date : 2023/3/30 16:28
  505. * @author : 寇珊珊
  506. */
  507. setBlameMessage(list) {
  508. this.blameNodeId = list[0].nodeId
  509. let obj = Object.assign(this.detailList[0], {
  510. blameNodeId: list[0].nodeId,
  511. blameNodeName: list[0].nodeName,
  512. //责任工号
  513. blameUserId: list[0].userId,
  514. blameUserName: list[0].userName,
  515. userName: list[0].userName,
  516. //责任工种
  517. blameWsJobId: list[0].jobId,
  518. blameWsJobName: list[0].jobName,
  519. jobName: list[0].jobName,
  520. })
  521. this.userId = list[0].userId
  522. this.jobId = list[0].jobId
  523. this.detailColumns[6].disabled = true
  524. this.detailColumns[7].disabled = true
  525. this.$set(this.detailList, 0, obj)
  526. //员工
  527. this.staffList = list[0].clockList
  528. for (let i of this.staffList) {
  529. i.blameStaffId = i.staffId
  530. i.blameWsJobId = i.jobId
  531. }
  532. let _this = this
  533. setTimeout(() => {
  534. _this.$refs['staff-table-select'].$refs.table.setCheckboxRow(
  535. _this.staffList.filter(it => it.defaultFlag), true)
  536. }, 200)
  537. },
  538. /**
  539. * @desc : 查询员工
  540. * @date : 2023/3/20 13:18
  541. * @author : 寇珊珊
  542. */
  543. getStaff() {
  544. if (this.blameNodeId) {
  545. return
  546. }
  547. let params = {
  548. ftyId: this.formData.ftyId,
  549. userId: this.userId ? parseInt(this.userId) : null,
  550. }
  551. this.excute(this.$service.commonService, this.$service.commonService.getTeamStaff, params).then(res => {
  552. if (res.code === this.$config.SUCCESS_CODE) {
  553. this.staffList = res.data.list
  554. for (let i of this.staffList) {
  555. i.blameStaffId = i.staffId
  556. i.blameWsJobId = i.jobId
  557. }
  558. let _this = this
  559. setTimeout(() => {
  560. _this.$refs['staff-table-select'].$refs.table.setCheckboxRow(
  561. _this.staffList.filter(it => it.defaultFlag), true)
  562. }, 200)
  563. } else {
  564. this.$Message.error(res.message)
  565. }
  566. })
  567. },
  568. //endregion
  569. //region 选择数据
  570. /**
  571. * @desc : 选择工位
  572. * @date : 2023/2/28 9:24
  573. * @author : 寇珊珊
  574. */
  575. chooseStation(row) {
  576. if (row && row[0]) {
  577. this.formData.stationId = row[0].stationId
  578. this.formData.stationName = row[0].stationName
  579. //校验打卡
  580. this.onProdUserCode()
  581. }
  582. },
  583. /**
  584. * @desc : 选择产品等级
  585. * @date : 2023/3/3 9:17
  586. * @author : 寇珊珊
  587. */
  588. chooseGrade(row) {
  589. if (row) {
  590. this.formData.opnGradeId = row
  591. let list = this.gradeList.filter(it => it.gradeId == row)
  592. if (list.length > 0) {
  593. this.formData.opnGradeKind = list[0].gradeKind
  594. //产品等级不为优
  595. if (this.formData.opnGradeKind != this.$config.gradeKindType.excellent) {
  596. //调用查询缺陷位置
  597. this.getDefectPlace()
  598. } else {
  599. this.detailList = []
  600. this.editDetailList = []
  601. // this.$set(this.detailList[0], 'readOnly', ['pdtPlaceId'])
  602. }
  603. }
  604. }
  605. },
  606. /**
  607. * @desc : 选择改变
  608. * @date : 2023/3/3 16:30
  609. * @author : 寇珊珊
  610. */
  611. chooseData(row, rowIndex, colItem) {
  612. this.rowIndex = rowIndex
  613. this.detailColumns[6].disabled = false
  614. this.detailColumns[7].disabled = false
  615. //缺陷扣罚
  616. if (colItem.field == 'dftFineId') {
  617. let list = this.defectFines.filter(it => it.fineId == row.dftFineId)
  618. if (list.length > 0) {
  619. row.deductNum = list[0].deductNum
  620. this.detailList[rowIndex] = Object.assign(this.detailList[rowIndex], {
  621. deductNum: list[0].deductNum,
  622. dftFineId: list[0].fineId,
  623. dftFineId_Name: list[0].fineName,
  624. dftFineName: list[0].fineName
  625. })
  626. }
  627. }
  628. //责任工序
  629. else if (colItem.field == 'blameNodeId') {
  630. let list = this.defectNodeList.filter(it => it.nodeId == row.blameNodeId)
  631. if (list.length > 0) {
  632. //赋值责任相关信息
  633. this.setBlameMessage(list)
  634. }
  635. }
  636. //责任工号
  637. else if (colItem.field == 'userName') {
  638. this.userId = row.userId
  639. this.detailList[rowIndex] = Object.assign(this.detailList[rowIndex], {
  640. blameUserId: row.userId,
  641. blameUserName: row.userName,
  642. })
  643. if (this.userId) {
  644. //查询员工
  645. this.getStaff()
  646. }
  647. }
  648. //责任工种
  649. else if (colItem.field == 'jobName') {
  650. this.jobId = row.jobId
  651. this.detailList[rowIndex] = Object.assign(this.detailList[rowIndex], {
  652. //责任工种
  653. blameWsJobId: row.jobId,
  654. blameWsJobName: row.jobName,
  655. })
  656. }
  657. //缺陷位置
  658. if (colItem.field == 'pdtPlaceId') {
  659. let list = this.defectPlaceList.filter(it => it.placeId == row.pdtPlaceId)
  660. if (list.length > 0) {
  661. this.detailList[rowIndex] = Object.assign(this.detailList[rowIndex], {
  662. pdtPlaceId: list[0].placeId,
  663. pdtPlaceId_Name: list[0].placeName,
  664. pdtPlaceName: list[0].placeName
  665. })
  666. }
  667. }
  668. this.$refs.recordTable.$refs.xTable.reloadData(this.$refs.recordTable.tableData)
  669. },
  670. /**
  671. * @desc : 值改变
  672. * @date : 2023/2/28 11:23
  673. * @author : 寇珊珊
  674. */
  675. changeValue(field, row, rowIndex) {
  676. this.rowIndex = rowIndex
  677. if (!this.detailList[rowIndex]) {
  678. this.detailList.splice(rowIndex, 0, {})
  679. }
  680. //缺陷编码
  681. if (field === 'defectCode') {
  682. if (!this.defectCode) {
  683. this.defectCode = row[field]
  684. } else {
  685. if (this.defectCode != row[field]) {
  686. this.detailList = []
  687. this.staffList = []
  688. this.defectCode = row[field]
  689. }
  690. }
  691. let params = {
  692. flowNodeId: this.flowNodeId,
  693. ftyId: this.formData.ftyId,
  694. defectCode: row[field],
  695. }
  696. this.excute(this.$service.collectService, this.$service.collectService.checkNodeDefectCode, params).then(res => {
  697. if (res.code === this.$config.SUCCESS_CODE) {
  698. this.$set(this.detailList[rowIndex], 'defectCode', row[field])
  699. //扣罚id
  700. this.$set(this.detailList[rowIndex], 'pdtDefectId', res.data.defectId)
  701. this.$set(this.detailList[rowIndex], 'defectName', res.data.defectName)
  702. this.pdtDefectId = res.data.defectId
  703. this.defectFines = res.data.defectFines
  704. //如果绑定缺陷扣罚Id 直接赋值
  705. if (true) {
  706. this.detailList[rowIndex].deductNum = this.defectFines[0].deductNum
  707. this.detailList[rowIndex].dftFineName = this.defectFines[0].fineName
  708. this.detailList[rowIndex].dftFineId = this.defectFines[0].fineId
  709. this.$set(this.detailList[rowIndex], 'readOnly', ['dftFineId'])
  710. }
  711. //查询缺陷数据
  712. this.getDefect(rowIndex)
  713. } else {
  714. this.$Message.error(res.message)
  715. }
  716. })
  717. } else if (field === 'blameNodeId') {
  718. this.detailList[rowIndex] = Object.assign(this.detailList[rowIndex], {
  719. blameNodeId: null,
  720. blameNodeName: null,
  721. //责任工号
  722. blameUserId: null,
  723. blameUserName: null,
  724. userName: null,
  725. //责任工种
  726. blameWsJobId: null,
  727. blameWsJobName: null,
  728. jobName: null,
  729. })
  730. this.userId = null
  731. this.jobId = null
  732. }
  733. },
  734. /**
  735. * @desc : 改变select类型值
  736. * @date : 2023/3/22 13:45
  737. * @author : 寇珊珊
  738. */
  739. clearSelect(value) {
  740. //清空 责任工序 和责任工序相关数据
  741. if (value.column.field === 'blameNodeId') {
  742. this.detailColumns[6].disabled = false
  743. this.detailColumns[7].disabled = false
  744. this.detailList[0] = Object.assign(this.detailList[0], {
  745. //责任工序
  746. blameNodeId: null,
  747. blameNodeName: null,
  748. //责任工号
  749. blameUserId: null,
  750. blameUserName: null,
  751. userName: null,
  752. //责任工种
  753. blameWsJobId: null,
  754. blameWsJobName: null,
  755. jobName: null,
  756. })
  757. this.$refs.recordTable.$refs.xTable.reloadData(this.$refs.recordTable.tableData)
  758. this.staffList = null
  759. this.userId = null
  760. this.jobId = null
  761. this.blameNodeId = null
  762. }
  763. },
  764. /**
  765. * @desc : 删除提交行数据
  766. * @date : 2023/3/10 11:26
  767. * @author : 寇珊珊
  768. */
  769. delSubmitTable(row, rowIndex) {
  770. this.editDetailList.splice(rowIndex, 1)
  771. if (row.prodDefectId) {
  772. this.productionDefectDelIdList.push(row.prodDefectId)
  773. }
  774. },
  775. //endregion
  776. //region 添加行+校验
  777. /**
  778. * @desc : 判重
  779. * @date : 2023/4/21 14:59
  780. * @author : 寇珊珊
  781. */
  782. checkRepetition(){
  783. //缺陷编码 + 缺陷位置 判重
  784. if(this.editDetailList && this.editDetailList.length>0){
  785. for(let i of this.editDetailList){
  786. if(this.detailList.filter(it=>it.placeCode == i.placeCode && it.pdtPlaceId ==i.pdtPlaceId).length>0){
  787. this.$Message.error(this.$t('W_114'))
  788. return false
  789. }
  790. }
  791. }
  792. return true
  793. },
  794. /**
  795. * @desc : 校验添加行数据
  796. * @date : 2023/3/10 9:09
  797. * @author : 寇珊珊
  798. */
  799. validDataAddRow() {
  800. let item = this.detailList[0]
  801. //region 缺陷编码
  802. if (item.defectCode == null) {
  803. this.$Message.error(this.$t('W_069', { 'param': this.$t('placeCode') }))
  804. this.setErrToRow(item, this.$t('W_093', {
  805. 'param': this.$t('defectCode')
  806. }))// 给行增加错误提示信息
  807. return false
  808. }
  809. //endregion
  810. //region 缺陷位置
  811. if (item && this.formData.opnGradeKind != this.$config.gradeKindType.excellent && item.pdtPlaceId == null) {
  812. this.$Message.error(this.$t('W_069', { 'param': this.$t('pdtPlaceId') }))
  813. this.setErrToRow(item, this.$t('W_093', {
  814. 'param': this.$t('pdtPlaceId')
  815. }))// 给行增加错误提示信息
  816. return false
  817. }
  818. //endregion
  819. //region 扣除数
  820. if (item.deductNum == null) {
  821. this.$Message.error(this.$t('W_069', { 'param': this.$t('deductNum') }))
  822. this.setErrToRow(item, this.$t('W_093', {
  823. 'param': this.$t('deductNum')
  824. }))// 给行增加错误提示信息
  825. return false
  826. }
  827. //endregion
  828. //region 责任工序 todo 目前不是必填的
  829. // if (item.blameNodeId == null) {
  830. // this.$Message.error(this.$t('W_069', { 'param': this.$t('blameNodeId') }))
  831. // this.setErrToRow(item, this.$t('W_093', {
  832. // 'param': this.$t('blameNodeId')
  833. // }))// 给行增加错误提示信息
  834. // return false
  835. // }
  836. //endregion
  837. //region 责任工号
  838. if (item.blameUserId == null) {
  839. this.$Message.error(this.$t('W_069', { 'param': this.$t('blameUserId') }))
  840. this.setErrToRow(item, this.$t('W_093', {
  841. 'param': this.$t('blameUserId')
  842. }))// 给行增加错误提示信息
  843. return false
  844. }
  845. //endregion
  846. //region 责任员工
  847. let list = this.$refs['staff-table-select'].$refs.table.getCheckboxRecords()
  848. if (list && list.length > 0) {
  849. for (let index = 0; index < list; index++) {
  850. let it = list[index]
  851. if (it.blameStaffId == null) {
  852. let rows = 1 + parseInt(index)
  853. this.$Message.error(this.$t('W_089', {
  854. 'param1': rows + this.$t('rowNo'),
  855. 'param2': this.$t('blameStaffId')
  856. }))
  857. this.setErrToRow(item, this.$t('W_093', {
  858. 'param': this.$t('blameStaffId')
  859. }))// 给行增加错误提示信息
  860. return false
  861. }
  862. }
  863. } else {
  864. this.$Message.error(this.$t('W_122'))
  865. return false
  866. }
  867. //endregion
  868. return true
  869. },
  870. /**
  871. * @desc : 添加行选择缺陷
  872. * @date : 2023/3/10 8:54
  873. * @author : 寇珊珊
  874. */
  875. addRow() {
  876. //添加行是否存在
  877. if (this.detailList.length == 0) {
  878. this.$Message.error(this.$t('W_116'))
  879. return false
  880. }
  881. //判重校验
  882. if (!this.checkRepetition()) {
  883. return
  884. }
  885. //校验添加行数据
  886. if (!this.validDataAddRow()) {
  887. return
  888. }
  889. this.detailList[0].info = null
  890. this.detailList[0].blameStaffName = this.$refs['staff-table-select'].$refs.table.getCheckboxRecords().map(map => map.staffName).toString()
  891. this.detailList[0].prodDefectStaffList = this.$refs['staff-table-select'].$refs.table.getCheckboxRecords()
  892. //缺陷编码
  893. this.detailList[0].pdtDefectCode = this.detailList[0].defectCode
  894. //缺陷名称
  895. this.detailList[0].pdtDefectName = this.detailList[0].defectName
  896. //缺陷扣罚
  897. this.detailList[0].dftFineName = this.detailList[0].dftFineName
  898. //责任工序
  899. this.detailList[0].blameNodeName = this.detailList[0].blameNodeName
  900. //责任工号
  901. this.detailList[0].blameUserName = this.detailList[0].blameUserName
  902. //责任工种
  903. this.detailList[0].blameWsJobName = this.detailList[0].blameJobName
  904. //缺陷位置
  905. this.detailList[0].pdtPlaceName = this.detailList[0].pdtPlaceName
  906. this.editDetailList.push(this.detailList[0])
  907. this.detailList = []
  908. this.staffList = []
  909. this.defectCode = null
  910. this.blameNodeId = null
  911. this.jobId = null
  912. this.userId = null
  913. },
  914. /**
  915. * @desc : 清空选择缺陷
  916. * @date : 2023/3/24 10:04
  917. * @author : 寇珊珊
  918. */
  919. clearRow() {
  920. this.defectCode = null
  921. this.detailList = []
  922. this.staffList = []
  923. },
  924. //endregion
  925. //region 缺陷位置
  926. /**
  927. * @desc : 查询缺陷位置
  928. * @date : 2023/3/15 14:56
  929. * @author : 寇珊珊
  930. */
  931. getDefectPlace() {
  932. let params = {
  933. modelId: this.modelId,
  934. ftyId: this.formData.ftyId,
  935. }
  936. this.excute(this.$service.collectService, this.$service.collectService.placeListBy, params).then(res => {
  937. if (res.code === this.$config.SUCCESS_CODE) {
  938. this.defectPlaceList = res.data
  939. } else {
  940. this.$Message.error(res.message)
  941. }
  942. })
  943. },
  944. /**
  945. * @desc : 保存缺陷位置
  946. * @date : 2023/3/13 14:07
  947. * @author : 寇珊珊
  948. */
  949. saveDefectPlace() {
  950. },
  951. //endregion
  952. //region 保存
  953. /**
  954. * @desc : 设置传参
  955. * @date : 2023/2/28 11:29
  956. * @author : 寇珊珊
  957. */
  958. setParams() {
  959. //校验名称是否重复
  960. if (!this.validData()) {
  961. return
  962. }
  963. this.params = JSON.parse(JSON.stringify(this.formData))
  964. this.params.barCodeList = [this.params.barCode]
  965. delete this.params.barCode
  966. this.params.productionDefectList = this.editDetailList.filter(it => !it.prodDefectId)
  967. this.params.productionDefectDelIdList = this.productionDefectDelIdList
  968. for (let it = 0; it < this.params.productionDefectList.length; it++) {
  969. //todo 劣品死数据 加上缺陷位置后删掉
  970. // "pdtViewImageId": 7,
  971. // "dftCoordinate": {},
  972. for (let i of this.params.productionDefectList[it].prodDefectStaffList) {
  973. if (this.params.productionDefectList[it].blameWsJobId) {
  974. i.blameWsJobId = this.params.productionDefectList[it].blameWsJobId
  975. } else {
  976. i.blameWsJobId = 0
  977. }
  978. }
  979. }
  980. this.params.flowNodeId = this.flowNodeId
  981. this.params.modelPdtLabelList = this.modelPdtLabelJson
  982. },
  983. /**
  984. * @desc : 校验重复数据
  985. * @date : 2023/3/8 8:45
  986. * @author : 寇珊珊
  987. */
  988. validData() {
  989. //判断是否有改判权限
  990. if (!this.gradeFlag) {
  991. this.$Message.error(this.$t('W_131'))
  992. return false
  993. }
  994. //判断是否存在明细 并且 产品等级为瑕、劣
  995. if (this.editDetailList.length == 0 &&
  996. (this.formData.opnGradeKind == this.$config.gradeKindType.flaw
  997. || this.formData.opnGradeKind == this.$config.gradeKindType.inferior)
  998. ) {
  999. this.$Message.error(this.$t('W_115'))
  1000. return false
  1001. }
  1002. //校验选择缺陷是否有数据
  1003. if (this.detailList && this.detailList.length == 1 && this.detailList[0].defectCode) {
  1004. this.$Message.error(this.$t('W_123'))
  1005. return false
  1006. }
  1007. let noList = []
  1008. noList = noList.concat(this.editDetailList.copy().filter(f => f.pdtDefectId).map(m => m.pdtDefectId + '-' + m.pdtPlaceId))
  1009. if (noList.length != noList.unique().length) {
  1010. this.$Message.error(this.$t('W_114'))
  1011. return false
  1012. }
  1013. return true
  1014. },
  1015. /**
  1016. * @desc : 保存数据
  1017. * @date : 2023/3/16 13:28
  1018. * @author : 寇珊珊
  1019. */
  1020. saveData() {
  1021. return this.excute(this.$service.collectService, '/', this.params)
  1022. },
  1023. //endregion
  1024. //region 清空+初始化数据
  1025. /**
  1026. * @desc : 清空
  1027. * @date : 2023/3/8 10:48
  1028. * @author : 寇珊珊
  1029. */
  1030. clear() {
  1031. //操作用户类型---生产工号不清空
  1032. if (this.userKind != this.$config.operationUserType.produceUser) {
  1033. this.formData.prodUserId = null
  1034. this.formData.prodUserCode = null
  1035. }
  1036. this.detailList = []
  1037. this.editDetailList = []
  1038. //todo 工位先暂时不清空 暂留 zdl 2023年3月29日09:01:41
  1039. // this.formData.stationId = null
  1040. // this.formData.stationName = ''
  1041. this.formData.barCode = ''
  1042. this.formData.productId = null
  1043. this.formData.productCode = ''
  1044. this.formData.productName = ''
  1045. this.formData.logoName = ''
  1046. this.formData.colourName = ''
  1047. this.formData.opnGradeId = null
  1048. this.formData.gradeName = null
  1049. this.formData.opnGradeKind = null
  1050. this.stationFlag = false
  1051. this.labelFlag = false
  1052. },
  1053. /**
  1054. * @desc : 获取工位
  1055. * @date : 2023/3/1 14:54
  1056. * @author : 寇珊珊
  1057. */
  1058. getWorkStation() {
  1059. let params = {
  1060. ftyId: this.formData.ftyId,
  1061. flowNodeId: this.flowNodeId,
  1062. }
  1063. this.excute(this.$service.commonService, this.$service.commonService.getWorkStation, params).then(res => {
  1064. if (res.code === this.$config.SUCCESS_CODE) {
  1065. this.workStationList = res.data
  1066. }
  1067. })
  1068. },
  1069. /**
  1070. * @desc : 查询产品等级
  1071. * @date : 2023/3/3 10:09
  1072. * @author : 寇珊珊
  1073. */
  1074. getGrade() {
  1075. let params = {
  1076. ftyId: this.formData.ftyId,
  1077. nodeId: this.flowNodeId,
  1078. }
  1079. this.excute(this.$service.commonService, this.$service.commonService.getProductGrade, params).then(res => {
  1080. if (res.code === this.$config.SUCCESS_CODE) {
  1081. this.gradeList = res.data
  1082. }
  1083. })
  1084. },
  1085. /**
  1086. * @desc : 根据节点id查询工序节点
  1087. * @date : 2023/3/9 9:55
  1088. * @author : 寇珊珊
  1089. */
  1090. selectProcessNode() {
  1091. this.excuteNoParam(this.$service.processNodeService, this.$service.processNodeService.selectById, [this.flowNodeId], false).then(res => {
  1092. if (res.code === this.$config.SUCCESS_CODE) {
  1093. //验证标签
  1094. if (res.data.flgCheckLabel) {
  1095. this.labelFlag = res.data.flgCheckLabel
  1096. this.pdtLabelKinds = res.data.pdtLabelKindList
  1097. for (let i of this.pdtLabelKinds) {
  1098. i['labelCode'] = ''
  1099. }
  1100. }
  1101. if (res.data.userKind == null) {
  1102. this.$Message.error(this.$t('W_117'))
  1103. return
  1104. }
  1105. this.userKind = res.data.userKind
  1106. //默认工位
  1107. if (res.data.stationId) {
  1108. this.formData.stationId = res.data.stationId
  1109. this.formData.stationName = res.data.stationName
  1110. this.stationFlag = true
  1111. }
  1112. //生产工号赋默认值 节点工号-生产
  1113. if (this.$config.operationUserType.produceUser == this.userKind) {
  1114. this.formData.prodUserCode = this.$store.state.user.userCode
  1115. this.formData.prodUserId = this.$store.state.user.id
  1116. //校验打卡
  1117. this.onProdUserCode()
  1118. }
  1119. } else {
  1120. this.$Message.error(res.message)
  1121. }
  1122. })
  1123. },
  1124. //endregion
  1125. },
  1126. activated() {
  1127. //改判权限标识
  1128. this.gradeFlag = this.$libaray.checkButtonHasRight('half-check-recharge')
  1129. //默认给新建为了保存不关页面
  1130. this.typeData = this.$config.formMode.add
  1131. //查询产品等级
  1132. this.getGrade()
  1133. //获取工位
  1134. this.getWorkStation()
  1135. //根据节点id查询工序节点
  1136. this.selectProcessNode()
  1137. },
  1138. }
  1139. </script>
  1140. <style scoped>
  1141. </style>