123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <template>
- <dialog-base ref="baseDialog" title="请选择">
- <!-- <view class="equipment-container uni-row ">
- <view v-for="(item, index) in equipments" :class="{'item':true,'selected': isSelected(item)}" :key="index"
- @click="handleSelection(item)"><text class="label">{{item['equipmentDetailCode']}}</text></view>
- </view> -->
- <view>
- <uni-section title="工序" type="line">
- <uni-data-select v-model="selectedProcess" :localdata="processList" :clear="false"
- @change="handleProcessChange"></uni-data-select>
- </uni-section>
- </view>
- <view>
- <uni-section title="设备" type="line">
- <uni-data-select v-model="selectedEquipment" :localdata="equipmentList" :clear="false"
- @change="handleEquipmentChange"></uni-data-select>
- </uni-section>
- </view>
- <view class="switch uni-row">
- <text class="label">是否邀请协作者</text>
- <view class="uni-row" style="align-items: center;">
- <text>否</text>
- <switch class="switch" @change="switchChange" />
- <text>是</text>
- </view>
- </view>
- <view v-if="flag">
- <uni-easyinput class="uni-mt-5" suffixIcon="search" focus v-model="userName" placeholder="请输入协作者编号"
- @iconClick="iconClick"></uni-easyinput>
- </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
- } from '@/utils/common.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)
- onLoad(() => {
- userId.value = store.userInfo.userId || "";
- })
- function init() {
- getProcessList({
- tenantId: store.tenantId,
- deptId: store.curDeptDetails
- }).then(res => {
- if (res.code == 200) {
- for (var i = 0; i < res.rows.length; i++) {
- processList.value[i] = {
- text: res.rows[i].processAlias,
- value: res.rows[i].processId
- }
- };
- selectedProcess.value = res.rows[0].processId;
- }
- })
- getEquipmentByUidAndDid(store.userInfo.userId, store.curDeptDetails).then(res => {
- if (res.code == 200) {
- getDayWorkItemList({
- userId: store.userInfo.userId,
- dayworkId: store.dayworkInfo.id,
- status: 1
- }).then(response => {
- equipmentList.value = res.rows
- if (response.code = 200) {
- for (let i = 0; i < res.rows.length; i++) {
- for (let j = 0; j < response.rows.length; j++) {
- if (response.rows[j].equipmentDetailId == res.rows[i].commonId) {
- equipmentList.value.splice(j, 1)
- }
- }
- };
- for (var i = 0; i < equipmentList.value.length; i++) {
- equipmentList.value[i] = {
- text: equipmentList.value[i].commonName,
- value: equipmentList.value[i]
- }
- };
- selectedEquipment.value = equipmentList.value[0];
- console.log(selectedEquipment.value)
- }
- })
- selectedEquipment.value = equipmentList.value[0];
- }
- })
- // let reqParam = {
- // userId: userId.value,
- // processId: store.dayworkInfo.currentProcess.id,
- // }
- // getUserequipmentList(reqParam).then(res => {
- // if (res.code == 200) {
- // equipments.value = res.rows
- // getDayWorkItemList({
- // userId: store.userInfo.userId,
- // dayworkId: store.dayworkInfo.id,
- // status: 1
- // }).then(response => {
- // // 过滤人员可选择的设备列表(选择之后不予展示)
- // for (let i = 0; i < response.rows.length; i++) {
- // for (let j = 0; j < equipments.value.length; j++) {
- // if (response.rows[i].equipmentDetailId == equipments.value[j]
- // .equipmentDetailId) {
- // equipments.value.splice(j, 1);
- // }
- // }
- // }
- // console.log(equipments.value)
- // baseDialog.value.open()
- // })
- // }
- // })
- baseDialog.value.open()
- }
- function open(data) {
- firstItem.value = data;
- init();
- }
- function close() {
- baseDialog.value.close()
- }
- defineExpose({
- open
- })
- function handleProcessChange() {
- }
- function handleEquipmentChange() {
- }
- function switchChange(e) {
- flag.value = e.detail.value;
- }
- // function handleSelection(item) {
- // // const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
- // // if (buttonIndex > -1) {
- // // selection.value.splice(buttonIndex, 1); // 取消选中
- // // } else {
- // // selection.value.push(item); // 选中
- // // }
- // selection.value[0] = item;
- // }
- function handleStart() {
- if (!selectedProcess.value || !selectedEquipment.value) {
- uni.showToast({
- icon: "none",
- title: "未选择工序或设备"
- })
- selectedProcess.value = null;
- selectedEquipment.value = null;
- return;
- }
- close();
- if (firstItem.value) {
- sendReqParam.value = {
- ...firstItem.value,
- processId: selectedProcess.value,
- equipmentDetailId: selectedEquipment.value.commonId,
- equipmentDetailCode: selectedEquipment.value.commonCode,
- startTime: timestampToTime(new Date()),
- status: 1
- };
- emit('handleAddDayWorkItem', sendReqParam.value);
- } else {
- emit('handleAddDayWorkItem', {
- processId: selectedProcess.value,
- equipmentDetailId: selectedEquipment.value.commonId,
- equipmentDetailCode: selectedEquipment.value.commonCode
- });
- }
- }
- </script>
- <style lang="scss">
- .dialog-body {
- .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;
- }
- }
- </style>
|