123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- <template>
- <view class="page-container uni-column">
- <view class="consultation-container uni-column">
- <view class="title uni-row">咨询</view>
- <view class="info-row uni-row">
- <view class="label">批次号</view>
- <view class="value">{{ lot.lotCode }}</view>
- </view>
- <view class="info-row uni-row">
- <view class="label">技术负责人</view>
- <view class="box-bg uni-row">
- <view class="input-view uni-row">
- <input class="nav-bar-input" type="text" disabled="true" v-model="lot.product.technicianName" />
- </view>
- <view class="search" @click="handleSwitch">
- <text style="padding-top: 5px;padding-right: 8px;color: aliceblue;">更换</text>
- </view>
- </view>
- <!-- <view class="value">{{ dayworkItem.technicianName }}</view> -->
- </view>
- <view class="info-row uni-row">
- <view class="label">产品描述</view>
- <view class="value">{{ lot.productDescription }}</view>
- </view>
- <view class="info-row uni-row">
- <view class="label">咨询部门</view>
- <view class="value">
- <checkbox-group @change="checkboxChange" style="margin-top: 16px;">
- <view v-for="(item, index) in consulteList" :key="item.value">
- <view class="uni-row checkbox-item">
- <view style="flex-grow: 1;font-size: 16px;">{{item.label}}</view>
- <view class="checkboxHidden">
- <checkbox :value="item.value" :checked="selected.includes(item.value)"
- color="#0000ff" class="checkbox" />
- </view>
- </view>
- <view v-if="index!=consulteList.length -1" class='middle'>
- <view class='segment'></view>
- <view class='segment'></view>
- </view>
- </view>
- </checkbox-group>
- </view>
- </view>
- <view class="info-row uni-column">
- <view class="label" style="margin-bottom: 16rpx;">问题描述</view>
- <view class="value uni-row">
- <textarea v-model="lot.question" maxlength="200"></textarea>
- </view>
- </view>
- <view class="info-row">
- <view class="label" style="margin-bottom: 16rpx;">照片</view>
- <view>
- <uni-file-picker :value="photoList.url" @select="select" file-mediatype="image" class="my-files"
- @delete="handleDeletedPhoto"></uni-file-picker>
- </view>
- </view>
- <view class="btn uni-row" @click.stop="handleSubmit">提交</view>
- </view>
- </view>
- </template>
- <script setup>
- import {
- ref,
- onMounted,
- getCurrentInstance
- } from 'vue'
- import {
- onLoad,
- onReady,
- onUnload,
- onShow
- } from '@dcloudio/uni-app'
- import {
- store
- } from '@/store/index.js'
- import {
- getProductConsult
- } from '@/api/business/processInspection.js'
- import {
- getURL
- } from '@/api/sys/user.js'
- const lot = ref({});
- const selected = ref([]);
- const selectedPhotos = ref([])
- const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
- const webHost = ref(urlList.pdfAppURL)
- const photoList = ref([])
- const consulteList = ref([{
- value: 0,
- label: "技术"
- },
- {
- value: 1,
- label: "品管"
- },
- ])
- // 创建一个引用来存储最后一次请求的时间戳
- const lastRequestTimestamp = ref(0);
- // 页面生命周期函数
- onShow(() => {
- uni.$off('addTechnicianEvent');
- })
- onMounted(() => {
- const instance = getCurrentInstance().proxy
- const eventChannel = instance.getOpenerEventChannel();
- eventChannel.on('factoryInpsectionConsultation', function(data) {
- console.log('show')
- console.log(lot.value)
- console.log('factoryInpsectionConsultation', data)
- // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
- if (data && data.data) {
- console.log(data.data)
- getProductConsult(data.data).then(res => {
- // console.log("res", res);
- if (res.code == 200) {
- lot.value = data.data
- lot.value.product = res.data
- lot.value.question = ''
- }
- })
- }
- })
- })
- onLoad(() => {})
- function upLoadImageHandler(arg) {
- return getURL(arg).then(res => {
- let data = JSON.parse(res)
- selectedPhotos.value.push({
- url: data.fileName,
- pictureName: data.originalFilename
- })
- console.log(selectedPhotos.value)
- // uni.showToast({
- // icon: 'none',
- // title: selectedPhotos.value.length,
- // duration: 2000
- // })
- })
- }
- function select(e) {
- console.log(e)
- const {
- tempFilePaths,
- tempFiles
- } = e
- uni.showLoading({
- title: '图片上传中',
- mask: true
- });
- // 创建一个空的Promise数组
- let uploadPromises = tempFiles.map((item, index) => {
- return upLoadImageHandler({
- filePath: tempFilePaths[index],
- name: item.name
- });
- });
- // 使用Promise.all等待所有图片上传完成
- Promise.all(uploadPromises).then(() => {
- // 上传完成后关闭加载提示
- uni.hideLoading();
- }).catch(() => {
- // 如果有错误发生,也关闭加载提示
- uni.hideLoading();
- });
- }
- function handleDeletedPhoto(e) {
- let fileName = selectedPhotos.value.map(info => info.name)
- let index = fileName.findIndex(name => name === e.tempFile.name);
- selectedPhotos.value.splice(index, 1)
- }
- //选中咨询部门数据
- function checkboxChange(value) {
- lot.value.departments = value.detail.value;
- }
- const handleSubmit = () => {
- if (lot.value.departments == null || (lot.value.departments != null && lot.value.departments.length == 0)) {
- uni.showToast({
- icon: 'none',
- title: '请选择咨询部门'
- })
- return
- }
- if (lot.value.departments.includes(0) && (lot.value.product.technicianId == undefined || lot.value.product
- .technicianId == 0)) {
- uni.showToast({
- icon: 'none',
- title: '请选择技术负责人'
- })
- return
- }
- if (lot.value.question == null || lot.value.question == '') {
- uni.showToast({
- icon: 'none',
- title: '请输入问题描述'
- })
- return
- }
- const currentTime = Date.now();
- // 检查是否已经过去了 2 秒
- if (currentTime - lastRequestTimestamp.value < 2000) {
- // 如果在 2 秒 内已经点击,那么不执行
- uni.showToast({
- icon: 'none',
- title: `请勿重复点击`,
- duration: 2000
- })
- return;
- }
- lastRequestTimestamp.value = currentTime;
- store.processInspection = null;
- var consultList = []
- for (let i = 0; i < lot.value.departments.length; i++) {
- let consult = {}
- consult.content = lot.value.question
- consult.consultDepartment = lot.value.departments[i]
- consult.pictures = selectedPhotos.value
- consult.technicianId = lot.value.product.technicianId
- consultList.push(consult)
- }
- uni.$emit('addWasteConsultationEvent', consultList)
- lot.value = {};
- uni.navigateBack()
- }
- const addTechnician = (data) => {
- console.log(data)
- lot.value.product.technicianId = data.technicianId
- lot.value.product.technicianName = data.technicianName
- }
- //切换技术负责人
- function handleSwitch() {
- uni.$on('addTechnicianEvent', (data) => {
- addTechnician(data)
- })
- console.log("777")
- uni.navigateTo({
- url: "/pages/sorting/technicianOptions"
- })
- }
- </script>
- <style lang="scss">
- .page-container {
- height: 100%;
- background-color: #ececec;
- font-size: 28rpx;
- padding: 24rpx;
- box-sizing: border-box;
- }
- .consultation-container {
- background-color: #ffffff;
- padding: 24rpx;
- border-radius: 12rpx;
- .title {
- justify-content: center;
- font-size: 32rpx;
- font-weight: 700;
- }
- .info-row {
- margin-top: 24rpx;
- .label {
- width: 180rpx;
- }
- .value {
- flex: 1;
- textarea {
- flex: 1;
- border: 1px solid #888888;
- box-sizing: border-box;
- padding: 16rpx;
- }
- }
- }
- .btn {
- background-color: #00D068;
- color: #ffffff;
- border-radius: 8rpx;
- margin: 24rpx;
- height: 64rpx;
- justify-content: center;
- align-items: center;
- }
- }
- .middle {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center
- }
- .segment {
- width: 60%;
- background-color: rgba(213, 213, 213, 1);
- border: 1rpx solid rgba(213, 213, 213, 1);
- margin: 8px 0;
- }
- .checkbox-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 10px;
- }
- .checkbox {
- margin-right: 10px;
- }
- // .uni-file-picker__container{
- // }
- .my-files {
- display: flex;
- justify-content: center;
- :deep(.uni-file-picker__container) {
- flex-direction: row;
- }
- }
- .box-bg {
- width: 94%;
- padding: 5rpx 16rpx;
- justify-content: space-around;
- align-items: center;
- .input-view {
- flex: 1;
- height: 60rpx;
- border: 1rpx solid #999;
- border-radius: 15rpx;
- border-top-right-radius: 0;
- border-bottom-right-radius: 0;
- padding: 0 15rpx;
- flex-wrap: nowrap;
- line-height: 60rpx;
- .input-uni-icon {
- line-height: 60rpx;
- }
- .nav-bar-input {
- width: 80%;
- height: 60rpx;
- line-height: 60rpx;
- padding: 0 5rpx;
- }
- }
- .search {
- width: 20%;
- text-align: center;
- background-color: #3e9fff;
- height: 60rpx;
- border-radius: 15rpx;
- border-top-left-radius: 0;
- border-bottom-left-radius: 0;
- border: 1rpx solid #999;
- padding-left: 10px;
- }
- }
- </style>
|