|
|
@ -6,11 +6,8 @@ |
|
|
|
<u-input v-model="form.describes" placeholder="请输入点检描述" /> |
|
|
|
</u-form-item> |
|
|
|
<u-form-item :label="`${type == 'DEVICE' ? '设备' : '模具'}编码`" prop="deviceNumber" required> |
|
|
|
<u-input v-model="form.deviceNumber" :placeholder="`请输入${type=='DEVICE'?'设备' : '模具'}编码`" @blur="blur" |
|
|
|
@confirm='blur()' /> |
|
|
|
<view class="right-button" @click="chickRightButton"> |
|
|
|
扫描 |
|
|
|
</view> |
|
|
|
<u-input v-model="form.deviceNumber" :placeholder="`请输入${type == 'DEVICE' ? '设备' : '模具'}编码`" @blur="blur" @confirm="blur()" /> |
|
|
|
<view class="right-button" @click="chickRightButton"> 扫描 </view> |
|
|
|
</u-form-item> |
|
|
|
<u-form-item :label="`${type == 'DEVICE' ? '设备' : '模具'}名称`" prop="deviceName" required class="disabled"> |
|
|
|
<u-input v-model="form.deviceName" :placeholder="`请输入${type == 'DEVICE' ? '设备' : '模具'}名称`" disabled /> |
|
|
@ -20,7 +17,7 @@ |
|
|
|
</u-form-item> |
|
|
|
<u-form-item label="班次" prop="classes" required> |
|
|
|
<view class="select" @click="openSingleColumn('classes', form.classes, maintenanceShift)"> |
|
|
|
<view class="input" v-if='form.classes'> |
|
|
|
<view class="input" v-if="form.classes"> |
|
|
|
{{ form.classesName }} |
|
|
|
</view> |
|
|
|
<view class="placeholder" v-else> |
|
|
@ -44,9 +41,7 @@ |
|
|
|
<u-row gutter="16"> |
|
|
|
<u-col :span="12"> |
|
|
|
<view class="dec"> |
|
|
|
<view class=""> |
|
|
|
设备部位名称: |
|
|
|
</view> |
|
|
|
<view class=""> 设备部位名称: </view> |
|
|
|
<view>{{ item.equipmentParts }}</view> |
|
|
|
</view> |
|
|
|
<view class="dec"> |
|
|
@ -63,25 +58,19 @@ |
|
|
|
<u-radio name="TRUE">符合</u-radio> |
|
|
|
<u-radio name="FALSE">不符合</u-radio> |
|
|
|
</u-radio-group> |
|
|
|
|
|
|
|
</view> |
|
|
|
<view class="dec"> |
|
|
|
<view class=""> |
|
|
|
<span v-if="item.numberNeedSwitch" class="required">*</span> |
|
|
|
巡检点检记录: |
|
|
|
</view> |
|
|
|
<u-input |
|
|
|
v-model="item.records" |
|
|
|
:placeholder="'请输入巡检点检记录'" |
|
|
|
:class="{'error': item.numberNeedSwitch && !item.records}" |
|
|
|
/> |
|
|
|
<u-input v-model="item.records" :placeholder="'请输入巡检点检记录'" :class="{ error: item.numberNeedSwitch && !item.records }" /> |
|
|
|
</view> |
|
|
|
<view class="image" style="margin-top: 20rpx;"> |
|
|
|
<view class="image" style="margin-top: 20rpx"> |
|
|
|
<view class="image-list" :key="refreshKey"> |
|
|
|
<view class="image-item" v-for="(element, index) in item.imgList" :key="index"> |
|
|
|
<image :src="element" mode=""></image> |
|
|
|
<u-icon name="close-circle-fill" color="red" class="close" size="36" @click="delImage(index)"> |
|
|
|
</u-icon> |
|
|
|
<u-icon name="close-circle-fill" color="red" class="close" size="36" @click="delImage(index)"> </u-icon> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="image-item image-item1" @click="chooseImage(item)"> |
|
|
@ -101,30 +90,24 @@ |
|
|
|
<view class="footer"> |
|
|
|
<view class="btns"> |
|
|
|
<button class="reset" @click="reset">重置</button> |
|
|
|
<button class="sure" @click="submit" :loading='loading' :disabled='loading'>确定</button> |
|
|
|
<button class="sure" @click="submit" :loading="loading" :disabled="loading">确定</button> |
|
|
|
</view> |
|
|
|
<view style="height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom);"></view> |
|
|
|
<view style="height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom)"></view> |
|
|
|
</view> |
|
|
|
<u-select v-model="singleColumnShow" mode="single-column" :default-value='singleColumnDefaultValue' |
|
|
|
:list="singleColumnList" @confirm="chooseSingleColumn" @cancle='singleColumnShow = false'></u-select> |
|
|
|
<u-select v-model="singleColumnShow" mode="single-column" :default-value="singleColumnDefaultValue" :list="singleColumnList" @confirm="chooseSingleColumn" @cancle="singleColumnShow = false"></u-select> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import { |
|
|
|
onLoad |
|
|
|
} from '@dcloudio/uni-app' |
|
|
|
import { |
|
|
|
ref, |
|
|
|
getCurrentInstance |
|
|
|
} from 'vue' |
|
|
|
import { onLoad } from '@dcloudio/uni-app' |
|
|
|
import { ref, getCurrentInstance } from 'vue' |
|
|
|
|
|
|
|
import * as deviceApi from "@/api/device" |
|
|
|
import * as moldApi from "@/api/mold" |
|
|
|
import * as spotCheckOrderApi from "@/api/spotCheckOrder" |
|
|
|
import * as dictApi from "@/api/dict" |
|
|
|
import * as deviceApi from '@/api/device' |
|
|
|
import * as moldApi from '@/api/mold' |
|
|
|
import * as spotCheckOrderApi from '@/api/spotCheckOrder' |
|
|
|
import * as dictApi from '@/api/dict' |
|
|
|
import { useCountStore } from '@/store' |
|
|
|
import * as uploadApi from "@/api/upload" |
|
|
|
import * as uploadApi from '@/api/upload' |
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() |
|
|
|
// 获取自定义的store |
|
|
@ -133,7 +116,8 @@ |
|
|
|
const loading = ref(false) |
|
|
|
const type = ref('') |
|
|
|
const imgList = ref([]) |
|
|
|
const list = ref([{ |
|
|
|
const list = ref([ |
|
|
|
{ |
|
|
|
name: 'apple', |
|
|
|
disabled: false |
|
|
|
}, |
|
|
@ -144,9 +128,10 @@ |
|
|
|
{ |
|
|
|
name: 'orange', |
|
|
|
disabled: false |
|
|
|
}]) |
|
|
|
} |
|
|
|
]) |
|
|
|
const form = ref({ |
|
|
|
describes: "", |
|
|
|
describes: '', |
|
|
|
deviceNumber: '', |
|
|
|
deviceName: '', |
|
|
|
maintenances: '', |
|
|
@ -159,16 +144,16 @@ |
|
|
|
const field = ref('') |
|
|
|
const maintenanceShift = ref([]) |
|
|
|
const subList = ref([]) |
|
|
|
const refreshKey = ref(0); |
|
|
|
const refreshKey = ref(0) |
|
|
|
// 扫描设备条码 |
|
|
|
function chickRightButton(field) { |
|
|
|
uni.scanCode({ |
|
|
|
success: function (res) { |
|
|
|
success(res) { |
|
|
|
form.value.deviceNumber = res.result |
|
|
|
getDetailsByNumber() |
|
|
|
getSubList() |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
function blur() { |
|
|
|
if (form.value.deviceNumber) { |
|
|
@ -183,75 +168,83 @@ |
|
|
|
flag: 2 |
|
|
|
} |
|
|
|
if (type.value == 'MOLD') { |
|
|
|
moldApi.getMoldDetailsByNumber(data).then((res) => { |
|
|
|
moldApi |
|
|
|
.getMoldDetailsByNumber(data) |
|
|
|
.then((res) => { |
|
|
|
if (res.data) { |
|
|
|
form.value.deviceName = res.data.name |
|
|
|
} else { |
|
|
|
proxy.$modal.showToast(`找不到该${type.value == 'DEVICE' ? '设备' : '模具'}`) |
|
|
|
} |
|
|
|
}).catch(() => { }) |
|
|
|
}) |
|
|
|
.catch(() => {}) |
|
|
|
} else { |
|
|
|
deviceApi.getDeviceDetailsByNumber(data).then((res) => { |
|
|
|
deviceApi |
|
|
|
.getDeviceDetailsByNumber(data) |
|
|
|
.then((res) => { |
|
|
|
if (res.data) { |
|
|
|
form.value.deviceName = res.data.name |
|
|
|
} else { |
|
|
|
proxy.$modal.showToast(`找不到该${type.value == 'DEVICE' ? '设备' : '模具'}`) |
|
|
|
} |
|
|
|
}).catch(() => { }) |
|
|
|
}) |
|
|
|
.catch(() => {}) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
// 根据设备获取二级列表 |
|
|
|
function getSubList() { |
|
|
|
const data = { |
|
|
|
number: form.value.deviceNumber |
|
|
|
} |
|
|
|
deviceApi.getSubList(data).then((res) => { |
|
|
|
deviceApi |
|
|
|
.getSubList(data) |
|
|
|
.then((res) => { |
|
|
|
if (res.data) { |
|
|
|
subList.value = res.data |
|
|
|
subList.value.forEach(item => { |
|
|
|
subList.value.forEach((item) => { |
|
|
|
item.isConform = 'TRUE' |
|
|
|
item.records = '' |
|
|
|
}) |
|
|
|
} else { |
|
|
|
proxy.$modal.showToast(`找不到该${type.value == 'DEVICE' ? '设备' : '模具'}`) |
|
|
|
} |
|
|
|
}).catch(() => { }) |
|
|
|
}) |
|
|
|
.catch(() => {}) |
|
|
|
} |
|
|
|
// 提交 |
|
|
|
function submit() { |
|
|
|
// 校验 |
|
|
|
if (!form.value.describes) { |
|
|
|
proxy.$modal.showToast('请输入点检描述'); |
|
|
|
return; |
|
|
|
proxy.$modal.showToast('请输入点检描述') |
|
|
|
return |
|
|
|
} |
|
|
|
if (!form.value.deviceNumber) { |
|
|
|
proxy.$modal.showToast(`请输入${type.value == 'DEVICE' ? '设备' : '模具'}编码`); |
|
|
|
return; |
|
|
|
proxy.$modal.showToast(`请输入${type.value == 'DEVICE' ? '设备' : '模具'}编码`) |
|
|
|
return |
|
|
|
} |
|
|
|
if (!form.value.classes) { |
|
|
|
proxy.$modal.showToast('请选择班次'); |
|
|
|
return; |
|
|
|
proxy.$modal.showToast('请选择班次') |
|
|
|
return |
|
|
|
} |
|
|
|
if (subList.value.length == 0) { |
|
|
|
proxy.$modal.showToast('该设备无检修项目'); |
|
|
|
return; |
|
|
|
proxy.$modal.showToast('该设备无检修项目') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 校验 subList 中的巡检点检记录 |
|
|
|
let hasError = false; |
|
|
|
subList.value.forEach(item => { |
|
|
|
let hasError = false |
|
|
|
subList.value.forEach((item) => { |
|
|
|
if (item.numberNeedSwitch && !item.records) { |
|
|
|
hasError = true; |
|
|
|
item.error = true; // 设置错误标记 |
|
|
|
hasError = true |
|
|
|
item.error = true // 设置错误标记 |
|
|
|
} else { |
|
|
|
item.error = false; // 清除错误标记 |
|
|
|
item.error = false // 清除错误标记 |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
if (hasError) { |
|
|
|
proxy.$modal.showToast('请填写所有必填的巡检点检记录'); |
|
|
|
return; |
|
|
|
proxy.$modal.showToast('请填写所有必填的巡检点检记录') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
const data = { |
|
|
@ -261,42 +254,46 @@ |
|
|
|
classes: form.value.classes, |
|
|
|
subList: subList.value, |
|
|
|
type: type.value |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
proxy.$modal.confirm('是否添加点检工单').then(() => { |
|
|
|
proxy.$modal.loading('加载中'); |
|
|
|
loading.value = true; |
|
|
|
spotCheckOrderApi.spotCheckOrderCreate(data, type.value).then((res) => { |
|
|
|
proxy.$modal.closeLoading(); |
|
|
|
proxy.$modal.loading('加载中') |
|
|
|
loading.value = true |
|
|
|
spotCheckOrderApi |
|
|
|
.spotCheckOrderCreate(data, type.value) |
|
|
|
.then((res) => { |
|
|
|
proxy.$modal.closeLoading() |
|
|
|
if (res.data) { |
|
|
|
proxy.$modal.showToast('添加成功'); |
|
|
|
proxy.$modal.showToast('添加成功') |
|
|
|
setTimeout(() => { |
|
|
|
proxy.$tab.navigateBack(); |
|
|
|
loading.value = false; |
|
|
|
}, 1500); |
|
|
|
proxy.$tab.navigateBack() |
|
|
|
loading.value = false |
|
|
|
}, 1500) |
|
|
|
} else { |
|
|
|
if (res.msg) { |
|
|
|
proxy.$modal.showToast(res.msg); |
|
|
|
proxy.$modal.showToast(res.msg) |
|
|
|
} else { |
|
|
|
proxy.$modal.showToast('添加失败'); |
|
|
|
proxy.$modal.showToast('添加失败') |
|
|
|
} |
|
|
|
loading.value = false; |
|
|
|
loading.value = false |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
proxy.$modal.closeLoading(); |
|
|
|
loading.value = false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
proxy.$modal.closeLoading() |
|
|
|
loading.value = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
// 重置 |
|
|
|
function reset() { |
|
|
|
form.value = { |
|
|
|
describes: "", |
|
|
|
describes: '', |
|
|
|
deviceNumber: '', |
|
|
|
deviceName: '', |
|
|
|
maintenances: '', |
|
|
|
classes: '' |
|
|
|
} |
|
|
|
subList.value = [] |
|
|
|
} |
|
|
|
|
|
|
|
// 单列模式 |
|
|
@ -304,7 +301,7 @@ |
|
|
|
singleColumnList.value = list |
|
|
|
field.value = fieldName |
|
|
|
if (val) { |
|
|
|
singleColumnDefaultValue.value = [list.findIndex(item => item.value == val)] |
|
|
|
singleColumnDefaultValue.value = [list.findIndex((item) => item.value == val)] |
|
|
|
} else { |
|
|
|
singleColumnDefaultValue.value = [] |
|
|
|
} |
|
|
@ -325,34 +322,37 @@ |
|
|
|
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有 |
|
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 |
|
|
|
success: (res) => { |
|
|
|
let filePath = res.tempFilePaths[0] |
|
|
|
const filePath = res.tempFilePaths[0] |
|
|
|
proxy.$modal.loading() |
|
|
|
const fileInfo = ref({ |
|
|
|
name: res.tempFiles[0].name, |
|
|
|
url: '' |
|
|
|
}) |
|
|
|
uploadApi.uploadFile({ |
|
|
|
filePath: filePath, |
|
|
|
uploadApi |
|
|
|
.uploadFile({ |
|
|
|
filePath, |
|
|
|
name: 'file', |
|
|
|
formData: { |
|
|
|
'user': 'test' |
|
|
|
}, |
|
|
|
}).then(ret => { |
|
|
|
if(dataItem['imgList']){ |
|
|
|
dataItem['imgList'].push(ret.data) |
|
|
|
user: 'test' |
|
|
|
} |
|
|
|
}) |
|
|
|
.then((ret) => { |
|
|
|
if (dataItem.imgList) { |
|
|
|
dataItem.imgList.push(ret.data) |
|
|
|
fileInfo.value.url = ret.data |
|
|
|
dataItem['fileInfoList'].push(fileInfo.value) |
|
|
|
dataItem.fileInfoList.push(fileInfo.value) |
|
|
|
} else { |
|
|
|
dataItem['imgList'] = [ret.data] |
|
|
|
dataItem.imgList = [ret.data] |
|
|
|
fileInfo.value.url = ret.data |
|
|
|
dataItem['fileInfoList'] = [fileInfo.value] |
|
|
|
dataItem.fileInfoList = [fileInfo.value] |
|
|
|
} |
|
|
|
proxy.$modal.closeLoading() |
|
|
|
}).catch((err) => { |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
proxy.$modal.closeLoading() |
|
|
|
}); |
|
|
|
}, |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// 删除图片 |
|
|
@ -360,15 +360,14 @@ |
|
|
|
imgList.value.splice(index, 1) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onLoad(async (option) => { |
|
|
|
if (option.type) type.value = option.type; |
|
|
|
if (option.type) type.value = option.type |
|
|
|
maintenanceShift.value = await dictApi.getDict('maintenance_shift') |
|
|
|
form.value.maintenances = uni.getStorageSync('user').nickname |
|
|
|
}) |
|
|
|
|
|
|
|
function radioGroupChange(e) { |
|
|
|
console.log(e); |
|
|
|
console.log(e) |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
@ -390,7 +389,7 @@ |
|
|
|
display: flex; |
|
|
|
margin-bottom: 20rpx; |
|
|
|
.item-box { |
|
|
|
background: #F5F5F5; |
|
|
|
background: #f5f5f5; |
|
|
|
border-radius: 12rpx; |
|
|
|
flex: 1; |
|
|
|
width: 0rpx; |
|
|
@ -456,7 +455,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
.reset { |
|
|
|
background: #F5F5F5; |
|
|
|
background: #f5f5f5; |
|
|
|
border-radius: 0px; |
|
|
|
&::after { |
|
|
|
border-radius: 0px; |
|
|
|