| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 |
- <template>
- <!-- 选择成型线 -->
- <div class="main-app">
- <!-- 顶部导航栏 -->
- <dk-app-nav-bar :title="title" @click-left="onClickLeft"></dk-app-nav-bar>
- <!-- 成型线编码-->
- <dk-app-field v-model="formDataView.uniqueCode" :label="$t('appMoldingCode')" ref="uniqueCode"
- placeholderType="scan" :readonly="false" @changeBarCode="onSearch" />
- <!-- 成型日期-->
- <dk-app-field v-model="formDataView.formingDate" :label="$t('appFormingDate')" :readonly="true"
- :defaultDateFlag="false" @click="showFormingDateClick" placeholderType="choose" is-link
- arrow-direction="down" />
- <!-- 成型批次-->
- <dk-app-field v-model="formDataView.moldingBatch" :label="$t('appGroutingBatch')" typeInput="number"
- :readonly="false" @changeBarCode="onSearch" />
- <!-- 分组序号-->
- <dk-app-field :focus="true" :readonly="false" :label="$t('appGroupNo')" typeInput="digit" @changeBarCode="onSearch"
- v-model="formDataView.groupName"></dk-app-field>
- <div class="main-app-table" ref="scrollTable">
- <van-list v-model="pageLoading" :immediate-check="false" :finished="pageFinished"
- :finished-text="$t('appNoMoreData')" @load="getData" offset="10">
- <!-- 列表-->
- <dk-app-table :rows="rows" :tableRowData="tableRowData" :checkboxFlag="true" :collapseFlag="false"
- :singleFlag="true" @onClickCheckbox="onClickCheckbox">
- </dk-app-table>
- </van-list>
- </div>
- <!-- 保存-->
- <div class="app_save_bottom-class" style="padding: 15px 10px 10px 10px">
- <dk-app-button @click="save">{{ $t('appDefine') }} </dk-app-button>
- </div>
- <!-- 单选天日期组件-->
- <dk-app-dropdown-single-date-day :show="showFormingDateFlag" @onConfirmChooseDate="onConfirmProduceDate"
- @onCloseChooseDate="onCloseChooseDate"></dk-app-dropdown-single-date-day>
- <dk-app-loading :loading="pageLoading"></dk-app-loading>
- </div>
- </template>
-
-
- <script>
- import { appIndexMixin } from "@/mixins/appindex";
- export default {
- name: "app-product-select-replace",
- mixins: [appIndexMixin],
- data() {
- return {
- title: this.$t('appProductSelectReplaceTitle'),
- showFormingDateFlag: false,
- tableRowData: [],
- chooseData: {},
- formData: {
- moldLineCode: '',//成型线编码
- productUniqueCode: '',//产品编码
- formingDate: '',
- moldingBatch: '',
- pdtBarcode: '',
- moldingUser: '',
- uniqueCode: '',
- groupName: '',
- },
- formDataView: {
- moldLineCode: '',//成型线编码
- productUniqueCode: '',//产品编码
- formingDate: '',
- moldingBatch: '',
- pdtBarcode: '',
- moldingUser: '',
- uniqueCode: '',
- groupName: '',
- },
- rows: [
- { name: 'moldingBatch', title: this.$t('moldingBatch') },
- { name: 'moldingDate', title: this.$t('moldingDate') },
- { name: 'moldlineItemNo', title: this.$t('groupNo') },
- { name: 'moldlineItemCode', title: this.$t('groupName') },
- { name: 'uniqueCode', title: this.$t('moldlineCode') },
- { name: 'moldlineName', title: this.$t('moldlineName') },
- { name: 'modelCode', title: this.$t('productCode') },
- { name: 'modelName', title: this.$t('productName') },
- { name: 'mouldCode', title: this.$t('moldingModelCode') },
- { name: 'moldlineItemKindName', title: this.$t('mouldKind') },
- ],
- pageLoading: false,//是否处于加载状态,加载过程中不触发load事件
- pageFinished: false,//是否已加载完成,加载完成后不再触发load事件
- page: 1,
- page_size: 10,
- pageTotal: 0,
- }
- },
- methods: {
- /**
- * @desc : 成型日期确定事件
- * @author : 于继渤
- * @date : 2023/2/13 13:39
- */
- onConfirmProduceDate(e) {
- this.formData.formingDate = e.date;
- this.showFormingDateFlag = false;
- },
- /**
- * @desc : 成型日期关闭事件
- * @author : 于继渤
- * @date : 2023/2/13 14:28
- */
- onCloseChooseDate() {
- this.showFormingDateFlag = false;
- },
- /**
- * @desc : 设置查询参数
- * @date : 2023/02/01
- * @author : 于继渤
- */
- setSearchParams() {
- let params = {}
- if (this.key === 'add') {
- //查询可添加绑定条码的产品
- params.modelIdList = []
- if (this.formData.bomItems && this.formData.bomItems.length > 0) {
- this.formData.bomItems.forEach(res => {
- params.modelIdList.push(res.mouldId)
- })
- }
- params.moldlineId = this.moldlineId
- params.pdtModelId = -999
- params.total = 0
- params.default = null
- } else {
- //查询可替换绑定条码的产品
- params.pdtGlueKind = this.formData.pdtGlueKind
- params.pdtModelId = this.formData.repPdtModelId
- }
- params.currentPage = this.page
- params.pageSize = this.page_size
- params.ftyId = this.$store.state.user.ftyId
- params.moldingBatch = this.formDataView.moldingBatch //成型批次
- params.uniqueCode = this.formDataView.uniqueCode //成型编码
- params.moldingDateStart = this.formDataView.formingDate //成型日期
- params.moldingDateEnd = this.formDataView.formingDate
- params.groupName = this.formDataView.groupName //分组序号
- return params
- },
- /**
- * @desc : 获取数据
- * @date : 2023/02/01
- * @author : 于继渤
- */
- getData() {
- this.pageLoading = true
- // 参数设置
- let params = this.setSearchParams()
- //默认 查询可替换绑定条码的产品
- let API = this.$service.moldingRecordItemService.selectProductByBindBarcode
- if (this.key === 'add') {
- //查询可添加绑定条码的产品
- API = this.$service.moldingRecordItemService.selectProductCanBindBarcode
- }
- this.excute(this.$service.moldingRecordItemService, API, params)
- .then(res => {
- if (res.code === this.$config.SUCCESS_CODE) {
- this.tableRowData = this.tableRowData.concat(res.data.list)
- if (this.page == 1) {
- this.pageTotal = Math.ceil(res.data.total / this.page_size);
- }
- // loading为false,此时会根据列表滚动位置判断是否触发load事件(列表内容不足一屏幕时,会直接触发)
- this.pageLoading = false
- if (this.page >= this.pageTotal) {
- // 数据全部加载完成
- this.pageFinished = true;
- }
- this.tableRowData.length === 0 ? (this.finishedText = "暂无数据") : (this.finishedText = "没有更多了");
- this.page++
- } else {
- this.pageFinished = true;
- this.pageLoading = false;
- }
- })
- },
- /**
- * @desc : 搜索事件
- * @author : 于继渤
- * @date : 2023/2/7 17:23
- */
- onSearch(e) {
- this.page = 1
- this.tableRowData = []
- //获取数据
- this.getData()
- },
- /**
- * @desc : 点击复选框
- * @author : 于继渤
- * @date : 2023/2/7 17:23
- */
- onClickCheckbox(e) {
- },
- /**
- * @desc : 确定
- * @author : 于继渤
- * @date : 2023/3/9 14:01
- */
- save() {
- let obj = {}
- //处理数据
- this.tableRowData.forEach(res => {
- if (res.checked) {
- obj = res
- }
- })
- let tableRowDataTemp = this.tableRowData.filter(res => {
- return res.checked
- })
- //校验是否选择数据
- if (tableRowDataTemp.length == 0) {
- this.appToastFail(this.$t('W_017'))
- return
- }
- //判断页面中是否已有选择数据
- //没有重复数据
- if (this.tableList.bomItems.filter(it => it.pdtModelId == obj.pdtModelId && it.moldlineId == obj.moldlineId && it.moldlineItemNo == obj.moldlineItemNo).length == 0) {
- if (this.key !== 'add') {
- //替换明细
- this.checkDetailByBindBarCode(obj)
- }
- } else {
- //重复数据,提示错误
- this.appToastFail(this.$t('W_141'))
- return
- }
- let tempObj = {}
- if (this.key === 'add') {
- //新添明细
- obj['moldingItemId'] = obj.itemId
- tempObj = {
- key: 'add',
- children: obj,
- parentIndex: this.parentIndex
- }
- } else {
- //替换明细
- tempObj = {
- key: '',
- children: this.children,
- parentIndex: this.parentIndex
- }
- }
- //存缓存
- localStorage.setItem("app-product-select-replace-data", JSON.stringify(tempObj))
- //返回
- this.$router.go(-1)
- },
- /**
- * @desc : 处理数据
- * @author : 于继渤
- * @date : 2023/2/14 9:35
- */
- checkDetailByBindBarCode(row) {
- let children = this.tableList.bomItems
- for (let i in children) {
- //找到明细中需要替换的数据
- if (children[i].id == this.formData.id) {
- row.parentId = children[i].parentId
- row.hasChild = children[i].hasChild
- row.id = children[i].id
- row.readOnlyUniqueCode = children[i].readOnlyUniqueCode
- children[i] = row
- children.moldingItemId = children[i].itemId
- break
- }
- }
- this.children = children
- },
- /**
- * @desc : 日期打开事件
- * @author : 于继渤
- * @date : 2023/2/14 9:35
- */
- showFormingDateClick() {
- this.showFormingDateFlag = true;
- },
- /**
- * @desc : 成型日期确定事件
- * @author : 于继渤
- * @date : 2023/2/13 13:39
- */
- onConfirmProduceDate(e) {
- this.formData.formingDate = e.date;
- this.showFormingDateFlag = false;
- },
- /**
- * @desc : 成型日期关闭事件
- * @author : 于继渤
- * @date : 2023/2/13 14:28
- */
- onCloseChooseDate() {
- this.showFormingDateFlag = false;
- },
- },
- mounted() {
- // 设置滚动的位置和高度
- this.setAppTableHeight()
- },
- /**
- * @desc : 页面初始化
- * @author : 于继渤
- * @date : 2023/2/7 17:23
- */
- created(e) {
- if (this.$route.params) {
- this.formData = this.$route.params.item //上一页选择的数据对象
- this.key = this.$route.params.key //上一页选择的操作类型 替换/新添 (key:add)
- if (this.$route.params.key && this.$route.params.key === 'add') {
- this.moldlineId = this.$route.params.moldlineId //设置成型线id
- this.title = this.$t('appProductSelectAddReplaceTitle') //设置标题
- }
- this.parentIndex = this.$route.params.parentIndex //上一页选择的数据位置索引
- this.tableList = this.$route.params.tableList //上一页选择的数据
- this.onSearch()
- }
- }
- }
- </script>
-
- <style scoped>
- .van-cell--large {
- padding-top: 5px !important;
- padding-bottom: 0px !important;
- }
- </style>
-
|