product-select-replace.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <!-- 选择成型线 -->
  3. <div class="main-app">
  4. <!-- 顶部导航栏 -->
  5. <dk-app-nav-bar :title="title" @click-left="onClickLeft"></dk-app-nav-bar>
  6. <!-- 成型线编码-->
  7. <dk-app-field v-model="formDataView.uniqueCode" :label="$t('appMoldingCode')" ref="uniqueCode"
  8. placeholderType="scan" :readonly="false" @changeBarCode="onSearch" />
  9. <!-- 成型日期-->
  10. <dk-app-field v-model="formDataView.formingDate" :label="$t('appFormingDate')" :readonly="true"
  11. :defaultDateFlag="false" @click="showFormingDateClick" placeholderType="choose" is-link
  12. arrow-direction="down" />
  13. <!-- 成型批次-->
  14. <dk-app-field v-model="formDataView.moldingBatch" :label="$t('appGroutingBatch')" typeInput="number"
  15. :readonly="false" @changeBarCode="onSearch" />
  16. <!-- 分组序号-->
  17. <dk-app-field :focus="true" :readonly="false" :label="$t('appGroupNo')" typeInput="digit" @changeBarCode="onSearch"
  18. v-model="formDataView.groupName"></dk-app-field>
  19. <div class="main-app-table" ref="scrollTable">
  20. <van-list v-model="pageLoading" :immediate-check="false" :finished="pageFinished"
  21. :finished-text="$t('appNoMoreData')" @load="getData" offset="10">
  22. <!-- 列表-->
  23. <dk-app-table :rows="rows" :tableRowData="tableRowData" :checkboxFlag="true" :collapseFlag="false"
  24. :singleFlag="true" @onClickCheckbox="onClickCheckbox">
  25. </dk-app-table>
  26. </van-list>
  27. </div>
  28. <!-- 保存-->
  29. <div class="app_save_bottom-class" style="padding: 15px 10px 10px 10px">
  30. <dk-app-button @click="save">{{ $t('appDefine') }} </dk-app-button>
  31. </div>
  32. <!-- 单选天日期组件-->
  33. <dk-app-dropdown-single-date-day :show="showFormingDateFlag" @onConfirmChooseDate="onConfirmProduceDate"
  34. @onCloseChooseDate="onCloseChooseDate"></dk-app-dropdown-single-date-day>
  35. <dk-app-loading :loading="pageLoading"></dk-app-loading>
  36. </div>
  37. </template>
  38. <script>
  39. import { appIndexMixin } from "@/mixins/appindex";
  40. export default {
  41. name: "app-product-select-replace",
  42. mixins: [appIndexMixin],
  43. data() {
  44. return {
  45. title: this.$t('appProductSelectReplaceTitle'),
  46. showFormingDateFlag: false,
  47. tableRowData: [],
  48. chooseData: {},
  49. formData: {
  50. moldLineCode: '',//成型线编码
  51. productUniqueCode: '',//产品编码
  52. formingDate: '',
  53. moldingBatch: '',
  54. pdtBarcode: '',
  55. moldingUser: '',
  56. uniqueCode: '',
  57. groupName: '',
  58. },
  59. formDataView: {
  60. moldLineCode: '',//成型线编码
  61. productUniqueCode: '',//产品编码
  62. formingDate: '',
  63. moldingBatch: '',
  64. pdtBarcode: '',
  65. moldingUser: '',
  66. uniqueCode: '',
  67. groupName: '',
  68. },
  69. rows: [
  70. { name: 'moldingBatch', title: this.$t('moldingBatch') },
  71. { name: 'moldingDate', title: this.$t('moldingDate') },
  72. { name: 'moldlineItemNo', title: this.$t('groupNo') },
  73. { name: 'moldlineItemCode', title: this.$t('groupName') },
  74. { name: 'uniqueCode', title: this.$t('moldlineCode') },
  75. { name: 'moldlineName', title: this.$t('moldlineName') },
  76. { name: 'modelCode', title: this.$t('productCode') },
  77. { name: 'modelName', title: this.$t('productName') },
  78. { name: 'mouldCode', title: this.$t('moldingModelCode') },
  79. { name: 'moldlineItemKindName', title: this.$t('mouldKind') },
  80. ],
  81. pageLoading: false,//是否处于加载状态,加载过程中不触发load事件
  82. pageFinished: false,//是否已加载完成,加载完成后不再触发load事件
  83. page: 1,
  84. page_size: 10,
  85. pageTotal: 0,
  86. }
  87. },
  88. methods: {
  89. /**
  90. * @desc : 成型日期确定事件
  91. * @author : 于继渤
  92. * @date : 2023/2/13 13:39
  93. */
  94. onConfirmProduceDate(e) {
  95. this.formData.formingDate = e.date;
  96. this.showFormingDateFlag = false;
  97. },
  98. /**
  99. * @desc : 成型日期关闭事件
  100. * @author : 于继渤
  101. * @date : 2023/2/13 14:28
  102. */
  103. onCloseChooseDate() {
  104. this.showFormingDateFlag = false;
  105. },
  106. /**
  107. * @desc : 设置查询参数
  108. * @date : 2023/02/01
  109. * @author : 于继渤
  110. */
  111. setSearchParams() {
  112. let params = {}
  113. if (this.key === 'add') {
  114. //查询可添加绑定条码的产品
  115. params.modelIdList = []
  116. if (this.formData.bomItems && this.formData.bomItems.length > 0) {
  117. this.formData.bomItems.forEach(res => {
  118. params.modelIdList.push(res.mouldId)
  119. })
  120. }
  121. params.moldlineId = this.moldlineId
  122. params.pdtModelId = -999
  123. params.total = 0
  124. params.default = null
  125. } else {
  126. //查询可替换绑定条码的产品
  127. params.pdtGlueKind = this.formData.pdtGlueKind
  128. params.pdtModelId = this.formData.repPdtModelId
  129. }
  130. params.currentPage = this.page
  131. params.pageSize = this.page_size
  132. params.ftyId = this.$store.state.user.ftyId
  133. params.moldingBatch = this.formDataView.moldingBatch //成型批次
  134. params.uniqueCode = this.formDataView.uniqueCode //成型编码
  135. params.moldingDateStart = this.formDataView.formingDate //成型日期
  136. params.moldingDateEnd = this.formDataView.formingDate
  137. params.groupName = this.formDataView.groupName //分组序号
  138. return params
  139. },
  140. /**
  141. * @desc : 获取数据
  142. * @date : 2023/02/01
  143. * @author : 于继渤
  144. */
  145. getData() {
  146. this.pageLoading = true
  147. // 参数设置
  148. let params = this.setSearchParams()
  149. //默认 查询可替换绑定条码的产品
  150. let API = this.$service.moldingRecordItemService.selectProductByBindBarcode
  151. if (this.key === 'add') {
  152. //查询可添加绑定条码的产品
  153. API = this.$service.moldingRecordItemService.selectProductCanBindBarcode
  154. }
  155. this.excute(this.$service.moldingRecordItemService, API, params)
  156. .then(res => {
  157. if (res.code === this.$config.SUCCESS_CODE) {
  158. this.tableRowData = this.tableRowData.concat(res.data.list)
  159. if (this.page == 1) {
  160. this.pageTotal = Math.ceil(res.data.total / this.page_size);
  161. }
  162. // loading为false,此时会根据列表滚动位置判断是否触发load事件(列表内容不足一屏幕时,会直接触发)
  163. this.pageLoading = false
  164. if (this.page >= this.pageTotal) {
  165. // 数据全部加载完成
  166. this.pageFinished = true;
  167. }
  168. this.tableRowData.length === 0 ? (this.finishedText = "暂无数据") : (this.finishedText = "没有更多了");
  169. this.page++
  170. } else {
  171. this.pageFinished = true;
  172. this.pageLoading = false;
  173. }
  174. })
  175. },
  176. /**
  177. * @desc : 搜索事件
  178. * @author : 于继渤
  179. * @date : 2023/2/7 17:23
  180. */
  181. onSearch(e) {
  182. this.page = 1
  183. this.tableRowData = []
  184. //获取数据
  185. this.getData()
  186. },
  187. /**
  188. * @desc : 点击复选框
  189. * @author : 于继渤
  190. * @date : 2023/2/7 17:23
  191. */
  192. onClickCheckbox(e) {
  193. },
  194. /**
  195. * @desc : 确定
  196. * @author : 于继渤
  197. * @date : 2023/3/9 14:01
  198. */
  199. save() {
  200. let obj = {}
  201. //处理数据
  202. this.tableRowData.forEach(res => {
  203. if (res.checked) {
  204. obj = res
  205. }
  206. })
  207. let tableRowDataTemp = this.tableRowData.filter(res => {
  208. return res.checked
  209. })
  210. //校验是否选择数据
  211. if (tableRowDataTemp.length == 0) {
  212. this.appToastFail(this.$t('W_017'))
  213. return
  214. }
  215. //判断页面中是否已有选择数据
  216. //没有重复数据
  217. if (this.tableList.bomItems.filter(it => it.pdtModelId == obj.pdtModelId && it.moldlineId == obj.moldlineId && it.moldlineItemNo == obj.moldlineItemNo).length == 0) {
  218. if (this.key !== 'add') {
  219. //替换明细
  220. this.checkDetailByBindBarCode(obj)
  221. }
  222. } else {
  223. //重复数据,提示错误
  224. this.appToastFail(this.$t('W_141'))
  225. return
  226. }
  227. let tempObj = {}
  228. if (this.key === 'add') {
  229. //新添明细
  230. obj['moldingItemId'] = obj.itemId
  231. tempObj = {
  232. key: 'add',
  233. children: obj,
  234. parentIndex: this.parentIndex
  235. }
  236. } else {
  237. //替换明细
  238. tempObj = {
  239. key: '',
  240. children: this.children,
  241. parentIndex: this.parentIndex
  242. }
  243. }
  244. //存缓存
  245. localStorage.setItem("app-product-select-replace-data", JSON.stringify(tempObj))
  246. //返回
  247. this.$router.go(-1)
  248. },
  249. /**
  250. * @desc : 处理数据
  251. * @author : 于继渤
  252. * @date : 2023/2/14 9:35
  253. */
  254. checkDetailByBindBarCode(row) {
  255. let children = this.tableList.bomItems
  256. for (let i in children) {
  257. //找到明细中需要替换的数据
  258. if (children[i].id == this.formData.id) {
  259. row.parentId = children[i].parentId
  260. row.hasChild = children[i].hasChild
  261. row.id = children[i].id
  262. row.readOnlyUniqueCode = children[i].readOnlyUniqueCode
  263. children[i] = row
  264. children.moldingItemId = children[i].itemId
  265. break
  266. }
  267. }
  268. this.children = children
  269. },
  270. /**
  271. * @desc : 日期打开事件
  272. * @author : 于继渤
  273. * @date : 2023/2/14 9:35
  274. */
  275. showFormingDateClick() {
  276. this.showFormingDateFlag = true;
  277. },
  278. /**
  279. * @desc : 成型日期确定事件
  280. * @author : 于继渤
  281. * @date : 2023/2/13 13:39
  282. */
  283. onConfirmProduceDate(e) {
  284. this.formData.formingDate = e.date;
  285. this.showFormingDateFlag = false;
  286. },
  287. /**
  288. * @desc : 成型日期关闭事件
  289. * @author : 于继渤
  290. * @date : 2023/2/13 14:28
  291. */
  292. onCloseChooseDate() {
  293. this.showFormingDateFlag = false;
  294. },
  295. },
  296. mounted() {
  297. // 设置滚动的位置和高度
  298. this.setAppTableHeight()
  299. },
  300. /**
  301. * @desc : 页面初始化
  302. * @author : 于继渤
  303. * @date : 2023/2/7 17:23
  304. */
  305. created(e) {
  306. if (this.$route.params) {
  307. this.formData = this.$route.params.item //上一页选择的数据对象
  308. this.key = this.$route.params.key //上一页选择的操作类型 替换/新添 (key:add)
  309. if (this.$route.params.key && this.$route.params.key === 'add') {
  310. this.moldlineId = this.$route.params.moldlineId //设置成型线id
  311. this.title = this.$t('appProductSelectAddReplaceTitle') //设置标题
  312. }
  313. this.parentIndex = this.$route.params.parentIndex //上一页选择的数据位置索引
  314. this.tableList = this.$route.params.tableList //上一页选择的数据
  315. this.onSearch()
  316. }
  317. }
  318. }
  319. </script>
  320. <style scoped>
  321. .van-cell--large {
  322. padding-top: 5px !important;
  323. padding-bottom: 0px !important;
  324. }
  325. </style>