123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <template>
- <dialog-base ref="baseDialog" title="请选择" style="margin: -250rpx auto 0 auto;">
- <view>
- <uni-section title="设备" type="line">
- <!-- <uni-data-select v-model="selectedEquipment" :localdata="equipmentList" :clear="false"
- @change="handleEquipmentChange"></uni-data-select> -->
- <zxz-uni-data-select v-model="selectedEquipment" filterable :localdata="equipmentList"
- placeholder="请选择/输入设备"></zxz-uni-data-select>
- </uni-section>
- </view>
- <view class="add-btn-container uni-row">
- <button type="primary" class="btn" @click="handleStart">开始</button>
- </view>
- </dialog-base>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onLoad
- } from '@dcloudio/uni-app'
- import {
- getProcessList
- } from '@/api/business/deptProcess.js'
- import {
- getUserequipmentList
- } from '@/api/business/userEquipment/userEquipment.js'
- import {
- getUserInfo
- } from '@/api/login/index.js'
- import {
- saveDayWorkItem,
- getDayWorkItemList
- } from '@/api/business/dayWorkItem.js'
- import {
- store
- } from '@/store/index.js'
- import {
- getEquipmentByUidAndDid
- } from '@/api/resourceGroup/resourceGroupDetail.js'
- import {
- timestampToTime,
- debounce
- } from '@/utils/common.js'
- import {
- getUserByLikeUsername
- } from '@/api/sys/user.js'
- const baseDialog = ref(null)
- const equipments = ref([]) // 接收设备列表信息
- const equipmentList = ref([])
- const emit = defineEmits(['handleAddDayWorkItem'])
- const userId = ref(null)
- const firstItem = ref(null);
- const sendReqParam = ref({})
- const processList = ref([])
- const selectedProcess = ref(null)
- const selectedEquipment = ref(null)
- const flag = ref(false)
- const userName = ref(null)
- const userList = ref([])
- const selectedUserList = ref([])
- const showProcessList = ref(true)
- onLoad(() => {
- userId.value = store.userInfo.userId || "";
- })
- function resetPage() {
- flag.value = false;
- userName.value = null;
- userList.value = [];
- equipmentList.value = [];
- selectedEquipment.value = null;
- selectedUserList.value = [];
- selectedProcess.value = null;
- processList.value = [];
- showProcessList.value = true;
- }
- function init() {
- getProcessList({
- // tenantId: store.tenantId,
- deptId: store.curDeptDetails.deptId,
- dayworkId: store.dayworkInfo.id
- }).then(res => {
- console.log(res)
- if (res.code == 200) {
- //过滤出工序交集store.dayworkInfo.processSequence
- let filteredData = store.dayworkInfo.processSequence.filter((item1) => {
- return res.data.some(item2 => item2.processCode === item1.processCode) &&
- store.dayworkInfo.currentProcess.processStepNumber === item1.processStepNumber;
- });
- console.log(filteredData)
- /* 20240409 修改
- for (let i = 0; i < filteredData.length; i++) {
- // console.log(processList.value)
- processList.value[i] = {
- text: filteredData[i].processAlias,
- value: filteredData[i].technologicalProcessDetailId,
- processId: filterData[i].id
- // value: filteredData[i].id
- }
- // console.log(processList.value)
- }
- */
- console.log(store.dayworkInfo)
- processList.value = filteredData.map(v => ({
- text: v.processAlias,
- value: v.technologicalProcessDetailId,
- processId: v.id,
- processStepNumber: store.dayworkInfo.currentProcess.processStepNumber
- }))
- console.log(processList.value)
- selectedProcess.value = filteredData[0].technologicalProcessDetailId;
- // selectedProcess.value = filteredData[0].processId
- // console.log(selectedProcess.value)
- isDefaultItem(firstItem.value);
- }
- })
- // Promise.all([getEquipmentByUidAndDid(store.planDetails.id), getDayWorkItemList({
- // // userId: store.userInfo.userId,
- // // dayworkId: store.dayworkInfo.id,
- // status: 1
- // })])
- // .then(([equipmentRes, response]) => {
- // console.log(equipmentRes)
- // console.log(response.rows)
- // if (equipmentRes.code == 200 && response.code == 200) {
- // let equipmentListData = equipmentRes.rows.filter((equipment) => {
- // return !response.rows.some((item) => item.equipmentDetailId == equipment.commonId);
- // });
- // equipmentList.value = equipmentListData.map((equipment) => {
- // return {
- // text: equipment.commonCode,
- // value: equipment
- // }
- // });
- // selectedEquipment.value = equipmentListData.length > 0 ? equipmentListData[0] : null;
- // }
- // baseDialog.value.open()
- // });
- getEquipmentByUidAndDid(store.planDetails.id, store.curDeptDetails.deptId, store.dayworkInfo.lotId).then(
- equipmentRes => {
- if (equipmentRes.code == 200) {
- for (var i = 0; i < equipmentRes.rows.length; i++) {
- equipmentList.value[i] = {
- text: equipmentRes.rows[i].commonCode,
- value: equipmentRes.rows[i]
- }
- }
- // selectedEquipment.value = equipmentRes.rows.length > 0 ? equipmentRes.rows[0] : null;
- }
- baseDialog.value.open()
- })
- }
- function open(data) {
- resetPage()
- firstItem.value = data;
- console.log(store.dayworkInfo)
- userName.value = null;
- userList.value = [];
- init();
- }
- function isDefaultItem(item) {
- if (item) {
- showProcessList.value = false;
- selectedProcess.value = null;
- }
- }
- function close() {
- baseDialog.value.close()
- }
- defineExpose({
- open
- })
- function handleProcessChange() {
- }
- function handleEquipmentChange() {
- }
- function handleSearchUserName() {
- if (userName.value) {
- getUserByLikeUsername(userName.value).then(res => {
- if (res.code == 200) {
- userList.value = res.data;
- }
- })
- }
- }
- function handleClickUserName(item) {
- selectedUserList.value.push(item);
- userList.value = [];
- }
- function handleBlur() {
- setTimeout(function() {
- userList.value = [];
- }, 200)
- }
- function handleRemoveUserName(item) {
- selectedUserList.value.splice(selectedUserList.value.indexOf(item), 1);
- }
- function switchChange(e) {
- flag.value = e.detail.value;
- }
- function handleStart() {
- uni.showModal({
- title: "提示",
- content: "确认开始新的报工吗",
- success: function(res) {
- if (res.confirm) {
- handleDoStart();
- } else if (res.cancel) {
- close();
- }
- }
- })
- }
- function handleDoStart() {
- if (!selectedEquipment.value) {
- uni.showToast({
- icon: "none",
- title: "未选择设备"
- })
- selectedProcess.value = null;
- selectedEquipment.value = null;
- return;
- }
- close();
- if (firstItem.value) {
- sendReqParam.value = {
- ...firstItem.value,
- /* 20240408 前版本
- processId: selectedProcess.value,
- */
- technologicalProcessDetailId: store.dayworkInfo.processSequence.filter(v => v.processStepNumber ==
- store.dayworkInfo.currentProcess.processStepNumber)[0].technologicalProcessDetailId,
- processId: store.dayworkInfo.currentProcess.id,
- equipmentDetailId: selectedEquipment.value.commonId,
- processStepNumber: store.dayworkInfo.currentProcess.processStepNumber,
- equipmentDetailCode: selectedEquipment.value.commonCode,
- startTime: timestampToTime(new Date()),
- status: 1,
- collaborationList: selectedUserList.value
- };
- console.log(sendReqParam.value)
- emit('handleAddDayWorkItem', sendReqParam.value);
- } else {
- emit('handleAddDayWorkItem', {
- /* 20240408 前版本
- processId: selectedProcess.value,
- */
- technologicalProcessDetailId: store.dayworkInfo.processSequence.filter(v => v.processStepNumber ==
- store.dayworkInfo.currentProcess.processStepNumber)[0].technologicalProcessDetailId,
- processId: store.dayworkInfo.currentProcess.id,
- // processId: store.dayworkInfo.processSequence.findIndex(v => v.technologicalProcessDetailId === selectedProcess.value) >= 0 ? store.dayworkInfo.processSequence.find(v => v.technologicalProcessDetailId === selectedProcess.value).id : null,
- equipmentDetailId: selectedEquipment.value.commonId,
- processStepNumber: store.dayworkInfo.currentProcess.processStepNumber,
- equipmentDetailCode: selectedEquipment.value.commonCode,
- collaborationList: selectedUserList.value
- });
- }
- }
- </script>
- <style lang="scss">
- .dialog-container {
- .dialog-body {
- margin-top: 180rpx !important;
- margin-left: auto !important;
- margin-right: auto !important;
- .equipment-container {
- height: 300rpx;
- overflow: auto;
- flex-wrap: wrap;
- justify-content: flex-start;
- margin: 24rpx 0 0 7%;
- .item {
- width: 236rpx;
- height: 60rpx;
- text-align: center;
- line-height: 60rpx;
- border-radius: 6rpx;
- margin: 16rpx;
- flex: 0 0 40%;
- border: 1px solid #000000;
- }
- .selected {
- background-color: #1684fc;
- color: #FFF;
- }
- }
- .add-btn-container {
- margin-top: 32rpx;
- .btn {
- flex: 1;
- }
- }
- .switch {
- font-size: 26rpx;
- align-items: center;
- justify-content: space-between;
- margin: 16rpx;
- }
- .userList {
- border: 1rpx solid #1684fc;
- border-radius: 8rpx;
- max-height: 300rpx;
- overflow: auto;
- width: 100%;
- .showUser {
- justify-content: flex-start;
- flex-wrap: wrap;
- .user {
- border: 1rpx solid #999;
- border-radius: 8rpx;
- width: 150rpx;
- height: 50rpx;
- text-align: center;
- line-height: 50rpx;
- margin: 10rpx;
- overflow: auto;
- }
- }
- }
- .selectedUserList {
- width: 100%;
- justify-content: flex-start;
- flex-wrap: wrap;
- .selectedUser {
- border: 1rpx solid #999;
- border-radius: 8rpx;
- width: 150rpx;
- height: 50rpx;
- text-align: center;
- line-height: 50rpx;
- margin: 20rpx 20rpx 0 0;
- justify-content: space-around;
- }
- }
- }
- }
- </style>
|