123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <template>
- <dialog-base class="dialog-body" ref="baseDialog" title="添加新批次">
- <view class="prompt">
- <text>请选择工序、批次后再确认</text>
- </view>
- <uni-section title="请选择当前工序" type="square">
- <uni-data-select v-model="selectedProcess" :localdata="processList" :clear="false"
- @change="handleProcessChange"></uni-data-select>
- </uni-section>
- <view :class="{'list-container':true, 'selected':isSelected(item)}" @click="handleSelection(item,index)"
- v-for="(item, index) in form" :key="item.id">
- <view class="list-title"><text class="label">批次号:{{item.lotCode}}</text></view>
- <view class="list-container-item uni-row" style="border-top: 1px solid #e1e1e1;border-radius: 8rpx 8rpx 0 0;">
- <text class="label">产品描述</text>
- <text class="label value">{{item['productDescription']}}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label">关联箱号</text>
- <text class="label value">{{item['carrierName']}}</text>
- </view>
- <view class="list-container-item uni-row">
- <text class="label">投产数量</text>
- <text class="label value">{{item['prodNum']}}</text>
- </view>
- <view class="list-container-item uni-row" style="border-radius: 0 0 8rpx 8rpx;">
- <text class="label">上道工序</text>
- <text class="label value">{{item['process'].processAlias}}</text>
- </view>
- </view>
- <view class="add-btn-container uni-row">
- <button type="primary" class="btn" @click="handleConfirm">确认</button>
- </view>
- </dialog-base>
- </template>
- <script setup>
- import {
- ref,
- getCurrentInstance
- } from 'vue'
- import {
- getProcessList
- } from '@/api/business/deptProcess.js'
- import {
- store
- } from '@/store/index.js'
- const baseDialog = ref(null)
- const selectedButton = ref(null)
- const form = ref([])
- const emit = defineEmits(['submit'])
- const selection = ref([])
- const selectedProcess = ref(null)
- const processList = ref([])
- const open = (data) => {
- // console.log(dialog.value)
- form.value = data;
- baseDialog.value.open();
- selection.value = [];
- getProcesses();
- }
- const close = () => {
- baseDialog.value.close()
- }
- defineExpose({
- open
- })
- function getProcesses() {
- getProcessList({
- deptId: store.curDeptDetails.deptId,
- }).then(res => {
- if (res.code == 200) {
- //过滤工序列表将上道序及之前的工序去掉, 然后过滤出工序交集
- let curProcessSequence = [...store.planDetails.processSequence];
- console.log(curProcessSequence)
- console.log(form.value[0])
- for (let i = 0; i < curProcessSequence.length; i++) {
- if (curProcessSequence[i].id == form.value[0].processId) {
- curProcessSequence.splice(0,i + 1);
- console.log(curProcessSequence)
- break;
- }
- }
- console.log(curProcessSequence)
- let filteredData = curProcessSequence.filter((item1) =>
- res.data.some((item2) => item2.processCode === item1.processCode)
- );
- for (let i = 0; i < filteredData.length; i++) {
- processList.value[i] = {
- text: filteredData[i].processAlias,
- value: filteredData[i].id
- }
- }
- // selectedProcess.value = filteredData[0].processId;
- }
- })
- }
- function handleProcessChange() {
- }
- function handleConfirm() {
- // 添加选择的工序
- for (let i = 0; i < selection.value.length; i++) {
- selection.value[i].daywork.processId = selectedProcess.value;
- }
- console.log(selection.value)
- // 执行确认
- if (selectedProcess.value && selection.value.length > 0) {
- close();
- emit('submit', selection.value);
- uni.$emit('dayworkItemUpdate');
- } else {
- uni.showToast({
- icon: 'none',
- title: '请选择工序、批次后再确认'
- })
- }
- }
- function isSelected(item) {
- return selection.value.includes(item);
- }
- function handleSelection(item, index) {
- const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
- if (buttonIndex > -1) {
- selection.value.splice(buttonIndex, 1); // 取消选中
- } else {
- selection.value.push(item); // 选中
- }
- console.log(selection.value, "selection");
- }
- </script>
- <style lang="scss">
- .selected {
- border: 3rpx solid #1684fc;
- border-radius: 8rpx;
- }
- .dialog-body {
- overflow: auto;
- .list-title {
- margin: 10rpx 0 20rpx 0;
- .label {
- font-size: 32rpx;
- font-weight: bold;
- }
- }
- .prompt {
- color: red;
- margin: 8rpx auto 0;
- }
- .list-container {
- width: 96%;
- display: flex;
- align-items: flex-start;
- margin: 10rpx auto;
- padding: 2%;
- border-radius: 8rpx;
- overflow: auto;
- .list-container-item {
- width: 100%;
- border-bottom: 1px solid #e1e1e1;
- border-left: 1px solid #e1e1e1;
- border-right: 1px solid #e1e1e1;
- padding: 12rpx 8rpx;
- box-sizing: border-box;
- .label {
- font-size: 28rpx;
- color: gray;
- width: 144rpx;
- &.value {
- flex: 1;
- }
- }
- }
- }
- .add-btn-container {
- margin-top: 32rpx;
- .btn {
- flex: 1;
- }
- }
- }
- .selectedProcess {
- width: 88%;
- margin: 20rpx auto 40rpx;
- }
- </style>
|