123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <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 style="overflow: auto;">
- <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" style="word-wrap: break-word;">{{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['daywork'].temporaryProcessQualifiedNum}}</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>
- <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 {
- getProcessListByLot
- } from "@/api/business/lot.js"
- import {
- getProcessList
- } from '@/api/business/deptProcess.js'
- import {
- getExamine
- } from '@/api/business/dayworkItemExamine.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({})
- const allProcessList = ref([])
- const processList = ref([])
- const open = (data) => {
- console.log(data)
- form.value = data;
- baseDialog.value.open();
- selection.value = [];
- selectedProcess.value = {};
- processList.value = [];
- getProcesses();
- }
- const close = () => {
- baseDialog.value.close()
- }
- defineExpose({
- open
- })
- function getProcesses() {
- Promise.all([getProcessList({
- deptId: store.curDeptDetails.deptId,
- dayworkId: form.value.dayworkId
- }), getProcessListByLot({
- id: form.value[0].daywork.lotId,
- isWasteRecycling: form.value[0].daywork.isWasteRecycling,
- isAmend: form.value[0].daywork.isAmend,
- technologicalProcessId: form.value[0].technologicalProcessId
- })]).then(([res, response]) => {
- if (res.code == 200) {
- //过滤工序列表将上道序及之前的工序去掉, 然后过滤出工序交集
- // let curProcessSequence = [...store.planDetails.processSequence];
- let curProcessSequence = response.data
- allProcessList.value = curProcessSequence
- // 这里根据前一序当前工序 过滤工序列表。
- // 假设单批单改部分修改后 需要做其他修改
- /* // 20240408 前毛宇辰版本
- 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;
- }
- }
- */
- /* 20240408后版本 */
- // 过滤前序
- curProcessSequence = curProcessSequence.filter(v => (v.processStepNumber > form.value[0]
- .technologicalProcessDetail.processStepNumber))
- /* 20240408 修改完成 */
- console.log(curProcessSequence)
- let filteredData = curProcessSequence.filter((item1) =>
- res.data.some((item2) => item2.processCode === item1.processCode)
- );
- console.log(filteredData)
- for (let i = 0; i < filteredData.length; i++) {
- processList.value[i] = {
- text: filteredData[i].processAlias,
- value: filteredData[i].technologicalProcessDetailId ? filteredData[i]
- .technologicalProcessDetailId : filteredData[i].id,
- processId: filteredData[i].processId,
- processStepNumber: filteredData[i].processStepNumber
- }
- }
- console.log(processList.value)
- selectedProcess.value = filteredData[0].value;
- console.log(selectedProcess.value)
- }
- // console.log(selectedProcess.value)
- })
- }
- function handleProcessChange() {
- console.log(selectedProcess.value)
- }
- function handleConfirm() {
- // 添加选择的工序
- for (let i = 0; i < selection.value.length; i++) {
- selection.value[i].daywork.technologicalProcessDetailId = selectedProcess.value;
- selection.value[i].daywork.processStepNumber = processList.value.find(v => v.value === selectedProcess.value)
- ?.processStepNumber;
- selection.value[i].daywork.processId = processList.value.findIndex(v => v.value === selectedProcess.value) >=
- 0 ? processList.value.find(v => v.value === selectedProcess.value).processId : null
- console.log(processList.value.findIndex(v => v.value === selectedProcess.value) >= 0 ? processList.value.find(
- v => v.value === selectedProcess.value).processId : null)
- }
- console.log(selection.value)
- //执行确认
- var msg = ""
- if (selectedProcess.value && selection.value.length > 0) {
- //判断选择的批次里是否有废品回用的
- for (let i = 0; i < selection.value.length; i++) {
- if (selection.value[i].daywork.isWaste == 0) {
- msg += selection.value[i].lotCode + ","
- }
- }
- if (msg === "") {
- uni.showToast({
- icon: 'none',
- title: msg + "已被废弃"
- })
- } else {
- //判断选择最后一道序的时候是否审核通过
- let dayworkIds = []
- for (let i = 0; i < selection.value.length; i++) {
- // console.log(selection.value[i].daywork.processStepNumber)
- // console.log(selection.value[i].processSequence[selection.value[i].processSequence.length - 1]
- // .processStepNumber)
- if (selection.value[i].daywork.processStepNumber == allProcessList.value[allProcessList.value.length -
- 1].processStepNumber) {
- dayworkIds.push(selection.value[i].dayworkId)
- }
- }
- if (dayworkIds.length > 0) {
- getExamine({
- dayworkIds: dayworkIds
- })
- .then(res => {
- console.log(res.code);
- if (res.code === 200) {
- //处理成功情况
- close();
- emit('submit', selection.value);
- uni.$emit('dayworkItemUpdate');
- } else {
- uni.showModal({
- title: '提示',
- content: res.msg,
- });
- }
- })
- } else {
- close();
- emit('submit', selection.value);
- uni.$emit('dayworkItemUpdate');
- }
- // console.log(selection.value)
- }
- } 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: 94%;
- display: flex;
- align-items: flex-start;
- margin: 10rpx auto;
- padding: 8px 2% 16px 2%;
- border-radius: 8rpx;
- .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: 140rpx;
- &.value {
- flex: 1;
- }
- }
- }
- }
- .add-btn-container {
- margin-top: 32rpx;
- .btn {
- flex: 1;
- }
- }
- }
- .selectedProcess {
- width: 88%;
- margin: 20rpx auto 40rpx;
- }
- </style>
|