|
@@ -2,25 +2,56 @@
|
|
|
<hc-card-item class="hc-test-sample-card-item">
|
|
|
<template #header>
|
|
|
<div class="w-200px">
|
|
|
- <el-select v-model="searchForm.contractId" placeholder="选择合同段" filterable block>
|
|
|
- <el-option v-for="item in contractData" :key="item.id" :label="item.contractName" :value="item.id" />
|
|
|
+ <el-select
|
|
|
+ v-model="searchForm.contractId"
|
|
|
+ placeholder="选择合同段"
|
|
|
+ filterable
|
|
|
+ block
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in contractData"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.contractName"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div class="ml-2 w-250px">
|
|
|
- <hc-date-picker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
|
|
|
+ <hc-date-picker
|
|
|
+ :dates="betweenTime"
|
|
|
+ clearable
|
|
|
+ @change="betweenTimeUpdate"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div class="ml-2 w-250px">
|
|
|
- <hc-search-input v-model="searchForm.materialName" @search="searchClick" />
|
|
|
+ <hc-search-input
|
|
|
+ v-model="searchForm.materialName"
|
|
|
+ @search="searchClick"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
<template #extra>
|
|
|
- <el-tooltip content="注:此功能用以扫描设备故障时使用,谨慎点击" placement="top">
|
|
|
- <el-button type="primary" :disabled="tableCheckedKeys.length <= 0" @click="manualStorageClick">手动入库</el-button>
|
|
|
+ <el-tooltip
|
|
|
+ content="注:此功能用以扫描设备故障时使用,谨慎点击"
|
|
|
+ placement="top"
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :disabled="tableCheckedKeys.length <= 0"
|
|
|
+ @click="manualStorageClick"
|
|
|
+ :loading="manualStorageLoading"
|
|
|
+ >手动入库</el-button
|
|
|
+ >
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
<hc-table
|
|
|
- :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }"
|
|
|
- is-check :check-style="{ width: 29 }" @selection-change="tableSelection"
|
|
|
+ :column="tableColumn"
|
|
|
+ :datas="tableData"
|
|
|
+ :loading="tableLoading"
|
|
|
+ :index-style="{ width: 60 }"
|
|
|
+ is-check
|
|
|
+ :check-style="{ width: 29 }"
|
|
|
+ @selection-change="tableSelection"
|
|
|
/>
|
|
|
<template #action>
|
|
|
<hc-pages :pages="searchForm" @change="pageChange" />
|
|
@@ -29,11 +60,11 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onMounted, ref, watch } from 'vue'
|
|
|
-import { useAppStore } from '~src/store'
|
|
|
-import { getErtractInfo } from '~api/other'
|
|
|
-import { arrToId, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
-import mainApi from '~api/tentative/material/testSample'
|
|
|
+import { onMounted, ref, watch } from "vue";
|
|
|
+import { useAppStore } from "~src/store";
|
|
|
+import { getErtractInfo } from "~api/other";
|
|
|
+import { arrToId, getArrValue, getObjValue, isNullES } from "js-fast-way";
|
|
|
+import mainApi from "~api/tentative/material/testSample";
|
|
|
|
|
|
//参数
|
|
|
const props = defineProps({
|
|
@@ -41,131 +72,152 @@ const props = defineProps({
|
|
|
type: Object,
|
|
|
default: () => ({}),
|
|
|
},
|
|
|
-})
|
|
|
+});
|
|
|
|
|
|
//变量
|
|
|
-const store = useAppStore()
|
|
|
-const projectId = ref(store.getProjectId)
|
|
|
-const contractId = ref(store.getContractId)
|
|
|
+const store = useAppStore();
|
|
|
+const projectId = ref(store.getProjectId);
|
|
|
+const contractId = ref(store.getContractId);
|
|
|
|
|
|
//渲染完成
|
|
|
onMounted(() => {
|
|
|
- getContractData()
|
|
|
-})
|
|
|
+ getContractData();
|
|
|
+});
|
|
|
|
|
|
//监听数据
|
|
|
-const treeInfo = ref(props.tree)
|
|
|
-watch(() => props.tree, (obj) => {
|
|
|
- treeInfo.value = getObjValue(obj)
|
|
|
- searchClick()
|
|
|
-})
|
|
|
+const treeInfo = ref(props.tree);
|
|
|
+watch(
|
|
|
+ () => props.tree,
|
|
|
+ (obj) => {
|
|
|
+ treeInfo.value = getObjValue(obj);
|
|
|
+ searchClick();
|
|
|
+ }
|
|
|
+);
|
|
|
|
|
|
//搜索表单
|
|
|
const searchForm = ref({
|
|
|
- status: 1, startTime: null, endTime: null, materialName: null,
|
|
|
- current: 1, size: 20, total: 0,
|
|
|
-})
|
|
|
+ status: 1,
|
|
|
+ startTime: null,
|
|
|
+ endTime: null,
|
|
|
+ materialName: null,
|
|
|
+ current: 1,
|
|
|
+ size: 20,
|
|
|
+ total: 0,
|
|
|
+});
|
|
|
|
|
|
//获取合同段信息
|
|
|
-const contractData = ref([])
|
|
|
+const contractData = ref([]);
|
|
|
const getContractData = async () => {
|
|
|
const { data } = await getErtractInfo({
|
|
|
projectId: projectId.value,
|
|
|
contractId: contractId.value,
|
|
|
- })
|
|
|
- const res = getArrValue(data)
|
|
|
- contractData.value = res
|
|
|
- if (res.length <= 0) return
|
|
|
- let cid
|
|
|
+ });
|
|
|
+ const res = getArrValue(data);
|
|
|
+ contractData.value = res;
|
|
|
+ if (res.length <= 0) return;
|
|
|
+ let cid;
|
|
|
for (let i = 0; i < res.length; i++) {
|
|
|
if (contractId.value == res[i].id) {
|
|
|
- cid = res[i].id
|
|
|
+ cid = res[i].id;
|
|
|
}
|
|
|
}
|
|
|
- searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
|
|
|
- searchClick()
|
|
|
-}
|
|
|
+ searchForm.value.contractId = isNullES(cid) ? res[0].id : cid;
|
|
|
+ searchClick();
|
|
|
+};
|
|
|
|
|
|
//日期时间被选择
|
|
|
-const betweenTime = ref(null)
|
|
|
+const betweenTime = ref(null);
|
|
|
const betweenTimeUpdate = ({ arr }) => {
|
|
|
- betweenTime.value = arr
|
|
|
+ betweenTime.value = arr;
|
|
|
if (arr.length > 0) {
|
|
|
- searchForm.value.startTime = arr[0]
|
|
|
- searchForm.value.endTime = arr[1]
|
|
|
+ searchForm.value.startTime = arr[0];
|
|
|
+ searchForm.value.endTime = arr[1];
|
|
|
} else {
|
|
|
- searchForm.value.startTime = null
|
|
|
- searchForm.value.endTime = null
|
|
|
+ searchForm.value.startTime = null;
|
|
|
+ searchForm.value.endTime = null;
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
//搜索
|
|
|
const searchClick = () => {
|
|
|
- searchForm.value.current = 1
|
|
|
- getTableData()
|
|
|
-}
|
|
|
+ searchForm.value.current = 1;
|
|
|
+ getTableData();
|
|
|
+};
|
|
|
|
|
|
//分页被点击
|
|
|
const pageChange = ({ current, size }) => {
|
|
|
- searchForm.value.current = current
|
|
|
- searchForm.value.size = size
|
|
|
- getTableData()
|
|
|
-}
|
|
|
+ searchForm.value.current = current;
|
|
|
+ searchForm.value.size = size;
|
|
|
+ getTableData();
|
|
|
+};
|
|
|
|
|
|
//表格数据
|
|
|
const tableColumn = ref([
|
|
|
- { key: 'materialName', name: '样品名称' },
|
|
|
- { key: 'specificationModel', name: '规格型号', align: 'center' },
|
|
|
- { key: 'materialCount', name: '试样数量', align: 'center' },
|
|
|
- { key: 'calculationUnit', name: '试样单位', align: 'center' },
|
|
|
- { key: 'proposedPosition', name: '拟用部位' },
|
|
|
- { key: 'representativeCount', name: '代表数量', align: 'center' },
|
|
|
- { key: 'representativeUnit', name: '代表单位' },
|
|
|
- { key: 'userName', name: '取样人', align: 'center' },
|
|
|
- { key: 'entrustTime', name: '委托单上报时间', align: 'center' },
|
|
|
-])
|
|
|
-const tableData = ref([])
|
|
|
+ { key: "materialName", name: "样品名称" },
|
|
|
+ { key: "specificationModel", name: "规格型号", align: "center" },
|
|
|
+ { key: "materialCount", name: "试样数量", align: "center" },
|
|
|
+ { key: "calculationUnit", name: "试样单位", align: "center" },
|
|
|
+ { key: "proposedPosition", name: "拟用部位" },
|
|
|
+ { key: "representativeCount", name: "代表数量", align: "center" },
|
|
|
+ { key: "representativeUnit", name: "代表单位" },
|
|
|
+ { key: "userName", name: "取样人", align: "center" },
|
|
|
+ { key: "entrustTime", name: "委托单上报时间", align: "center" },
|
|
|
+]);
|
|
|
+const tableData = ref([]);
|
|
|
|
|
|
//获取表格数据
|
|
|
-const tableLoading = ref(false)
|
|
|
+const tableLoading = ref(false);
|
|
|
const getTableData = async () => {
|
|
|
- const { primaryKeyId } = treeInfo.value
|
|
|
- if (isNullES(primaryKeyId)) return
|
|
|
- tableLoading.value = true
|
|
|
+ const { primaryKeyId } = treeInfo.value;
|
|
|
+ if (isNullES(primaryKeyId)) return;
|
|
|
+ tableLoading.value = true;
|
|
|
const { error, code, data } = await mainApi.queryPage({
|
|
|
...searchForm.value,
|
|
|
projectId: projectId.value,
|
|
|
- nodeId: primaryKeyId || '',
|
|
|
- })
|
|
|
+ nodeId: primaryKeyId || "",
|
|
|
+ });
|
|
|
//处理数据
|
|
|
- tableLoading.value = false
|
|
|
+ tableLoading.value = false;
|
|
|
if (!error && code === 200) {
|
|
|
- tableData.value = getArrValue(data?.records)
|
|
|
- searchForm.value.total = data.total || 0
|
|
|
+ tableData.value = getArrValue(data?.records);
|
|
|
+ searchForm.value.total = data.total || 0;
|
|
|
} else {
|
|
|
- tableData.value = []
|
|
|
- searchForm.value.total = 0
|
|
|
+ tableData.value = [];
|
|
|
+ searchForm.value.total = 0;
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
//多选
|
|
|
-const tableCheckedKeys = ref([])
|
|
|
+const tableCheckedKeys = ref([]);
|
|
|
const tableSelection = (rows) => {
|
|
|
- tableCheckedKeys.value = rows
|
|
|
-}
|
|
|
+ tableCheckedKeys.value = rows;
|
|
|
+};
|
|
|
|
|
|
//手动入库
|
|
|
+const manualStorageLoading = ref(false);
|
|
|
const manualStorageClick = async () => {
|
|
|
- const rows = tableCheckedKeys.value
|
|
|
+ const rows = tableCheckedKeys.value;
|
|
|
//判断是否满足条件
|
|
|
const result = rows.every(({ rfId }) => {
|
|
|
- return !isNullES(rfId)
|
|
|
- })
|
|
|
+ return !isNullES(rfId);
|
|
|
+ });
|
|
|
if (!result) {
|
|
|
- window.$message?.warning('存在材料未使用RFID,无法手动入库')
|
|
|
- return
|
|
|
+ window.$message?.warning("存在材料未使用RFID,无法手动入库");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const ids = arrToId(rows);
|
|
|
+ manualStorageLoading.value = true;
|
|
|
+ const { error, code, msg } = await mainApi.update({
|
|
|
+ id: ids,
|
|
|
+ sampleStatus: 2,
|
|
|
+ });
|
|
|
+ manualStorageLoading.value = false;
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message.success(msg);
|
|
|
+
|
|
|
+ getTableData().then();
|
|
|
+ } else {
|
|
|
+ window.$message.error(msg || "操作失败");
|
|
|
}
|
|
|
- const ids = arrToId(rows)
|
|
|
- console.log(ids)
|
|
|
-}
|
|
|
+};
|
|
|
</script>
|