|
@@ -41,16 +41,19 @@
|
|
</div>
|
|
</div>
|
|
<div class="header" style="border-bottom: 0px">
|
|
<div class="header" style="border-bottom: 0px">
|
|
<div class="text">选择统计产品:</div>
|
|
<div class="text">选择统计产品:</div>
|
|
- <el-input size="small" placeholder="请输入产品名称" />
|
|
|
|
- <!-- <el-tree
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ size="small"
|
|
|
|
+ placeholder="请输入产品名称"
|
|
|
|
+ @click="openProdtForm"
|
|
|
|
+ />
|
|
|
|
+ <el-tree
|
|
ref="treeRef2"
|
|
ref="treeRef2"
|
|
- :data="data1"
|
|
|
|
- show-checkbox
|
|
|
|
|
|
+ :data="treeData"
|
|
default-expand-all
|
|
default-expand-all
|
|
- :default-checked-keys="['合格率']"
|
|
|
|
- node-key="key"
|
|
|
|
|
|
+ node-key="productName"
|
|
highlight-current
|
|
highlight-current
|
|
- /> -->
|
|
|
|
|
|
+ style="margin-top: 20px"
|
|
|
|
+ />
|
|
<!-- <el-tree
|
|
<!-- <el-tree
|
|
v-if="prodt.prodtName"
|
|
v-if="prodt.prodtName"
|
|
ref="treeRef2"
|
|
ref="treeRef2"
|
|
@@ -68,7 +71,7 @@
|
|
<div class="box">
|
|
<div class="box">
|
|
<div class="boxheader">
|
|
<div class="boxheader">
|
|
<div>
|
|
<div>
|
|
- <el-button type="primary" class="btn" @click="getTableData"
|
|
|
|
|
|
+ <el-button type="primary" class="btn" @click="getTableDataSearch"
|
|
>统计查询</el-button
|
|
>统计查询</el-button
|
|
>
|
|
>
|
|
<el-button class="btn" @click="reset">重置</el-button>
|
|
<el-button class="btn" @click="reset">重置</el-button>
|
|
@@ -99,7 +102,8 @@
|
|
/> -->
|
|
/> -->
|
|
<el-table-column prop="productLineName" label="车间名称" />
|
|
<el-table-column prop="productLineName" label="车间名称" />
|
|
<el-table-column prop="productName" label="产品名称" />
|
|
<el-table-column prop="productName" label="产品名称" />
|
|
- <el-table-column prop="productType" label="批次号" />
|
|
|
|
|
|
+ <el-table-column prop="productCode" label="产品编码" />
|
|
|
|
+ <el-table-column prop="batchNo" label="产品批次" />
|
|
<el-table-column prop="goodRate" label="良率" />
|
|
<el-table-column prop="goodRate" label="良率" />
|
|
<el-table-column prop="badRate" label="不良率" />
|
|
<el-table-column prop="badRate" label="不良率" />
|
|
<el-table-column prop="timeStr" label="日期" />
|
|
<el-table-column prop="timeStr" label="日期" />
|
|
@@ -119,6 +123,42 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <el-dialog title="选择统计产品" v-model="dialogVisible" width="60%" center>
|
|
|
|
+ <div>
|
|
|
|
+ <Search :searchOptions="searchForm" ref="searchRef" />
|
|
|
|
+ </div>
|
|
|
|
+ <div>
|
|
|
|
+ <el-table
|
|
|
|
+ :data="tableProdtData"
|
|
|
|
+ row-key="id"
|
|
|
|
+ border
|
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
|
+ >
|
|
|
|
+ <el-table-column type="selection" width="55" />
|
|
|
|
+ <el-table-column prop="productLineName" label="车间名称" />
|
|
|
|
+ <el-table-column prop="productName" label="产品名称" />
|
|
|
|
+ <el-table-column prop="productCode" label="产品编码" />
|
|
|
|
+ <el-table-column prop="batchNo" label="产品批次" />
|
|
|
|
+ <el-table-column prop="productType" label="产品类型" />
|
|
|
|
+ <el-table-column prop="timeStr" label="创建日期" />
|
|
|
|
+ </el-table>
|
|
|
|
+ <Pagination
|
|
|
|
+ :total="currentProdtOption.total"
|
|
|
|
+ :page="currentProdtOption.page"
|
|
|
|
+ :limit="currentProdtOption.limit"
|
|
|
|
+ :pageSizes="currentProdtOption.pageSizes"
|
|
|
|
+ v-model:page="currentProdtOption.page"
|
|
|
|
+ v-model:limit="currentProdtOption.limit"
|
|
|
|
+ @pagination="getProdtData"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ <div>
|
|
|
|
+ <el-button type="primary" class="btn" @click="handleConfirm"
|
|
|
|
+ >确定</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button class="btn" @click="dialogVisible = false">取消</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
@@ -126,6 +166,7 @@ import { getData, getStatLevel, getExport } from "@/api/statistic";
|
|
import { getMockData } from "@/api/statistic/firstPassYieldMockData";
|
|
import { getMockData } from "@/api/statistic/firstPassYieldMockData";
|
|
import Pagination from "@/components/Pagination/index.vue";
|
|
import Pagination from "@/components/Pagination/index.vue";
|
|
import { downFile } from "@/utils/common";
|
|
import { downFile } from "@/utils/common";
|
|
|
|
+import Search from "@/components/Search/index.vue";
|
|
|
|
|
|
defineOptions({
|
|
defineOptions({
|
|
name: "Dashboard",
|
|
name: "Dashboard",
|
|
@@ -207,7 +248,10 @@ const queryIndexs = ref([]);
|
|
// mock数据
|
|
// mock数据
|
|
const getTableData = async () => {
|
|
const getTableData = async () => {
|
|
queryIndexs.value = getValue(treeRef1.value.getCheckedNodes());
|
|
queryIndexs.value = getValue(treeRef1.value.getCheckedNodes());
|
|
- const { data } = await getMockData(); // 使用假数据函数
|
|
|
|
|
|
+ const { data } = await getMockData({
|
|
|
|
+ page: currentOption.value.page,
|
|
|
|
+ limit: currentOption.value.limit,
|
|
|
|
+ }); // 使用假数据函数
|
|
tableData.value = data.records;
|
|
tableData.value = data.records;
|
|
currentOption.value.total = data.totalCount;
|
|
currentOption.value.total = data.totalCount;
|
|
};
|
|
};
|
|
@@ -215,10 +259,13 @@ const getTableData = async () => {
|
|
|
|
|
|
const reset = () => {
|
|
const reset = () => {
|
|
value1.value = getCurrentMonthStartAndEndDates();
|
|
value1.value = getCurrentMonthStartAndEndDates();
|
|
- treeRef1.value.setCheckedKeys([statProductionLineData[0].key], true, true);
|
|
|
|
- treeRef2.value.setCheckedKeys([statProductTypeData[0].key], true, true);
|
|
|
|
|
|
+ // treeRef1.value.setCheckedKeys([statProductionLineData[0].key], true, true);
|
|
|
|
+ // treeRef2.value.setCheckedKeys([statProductTypeData[0].key], true, true);
|
|
radio.value = 1;
|
|
radio.value = 1;
|
|
currentOption.value.page = 1;
|
|
currentOption.value.page = 1;
|
|
|
|
+ treeData.value = [];
|
|
|
|
+ selectedRows.value = [];
|
|
|
|
+ tableData.value = [];
|
|
getTableData();
|
|
getTableData();
|
|
};
|
|
};
|
|
|
|
|
|
@@ -231,23 +278,131 @@ const statProductionLineData = ref([
|
|
},
|
|
},
|
|
]);
|
|
]);
|
|
|
|
|
|
-// const statProductTypeData = ref([
|
|
|
|
-// {
|
|
|
|
-// key: "productType",
|
|
|
|
-// label: "产品类型",
|
|
|
|
-// children: [
|
|
|
|
-// {
|
|
|
|
-// key: "productType1",
|
|
|
|
-// label: "类型1",
|
|
|
|
-// },
|
|
|
|
-// {
|
|
|
|
-// key: "productType2",
|
|
|
|
-// label: "类型2",
|
|
|
|
-// },
|
|
|
|
-// ],
|
|
|
|
-// },
|
|
|
|
-// ]);
|
|
|
|
|
|
+const tableProdtData = ref([]);
|
|
|
|
+const dialogVisible = ref(false);
|
|
|
|
+const searchRef = ref(null);
|
|
|
|
+const openProdtForm = async () => {
|
|
|
|
+ dialogVisible.value = true;
|
|
|
|
+ getProdtData();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const getProdtData = async () => {
|
|
|
|
+ const { data } = await getMockData({
|
|
|
|
+ page: currentProdtOption.value.page,
|
|
|
|
+ limit: currentProdtOption.value.limit,
|
|
|
|
+ }); // 使用假数据函数
|
|
|
|
+ tableProdtData.value = data.records;
|
|
|
|
+ currentProdtOption.value.total = data.totalCount;
|
|
|
|
+};
|
|
|
|
+const searchForm = [
|
|
|
|
+ {
|
|
|
|
+ label: "产品名称",
|
|
|
|
+ type: "input",
|
|
|
|
+ key: "prodtName",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "产品编码",
|
|
|
|
+ type: "input",
|
|
|
|
+ key: "prodtCode",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "产品类型",
|
|
|
|
+ type: "select",
|
|
|
|
+ key: "prodtType",
|
|
|
|
+ options: [
|
|
|
|
+ {
|
|
|
|
+ label: "类型1",
|
|
|
|
+ value: "1",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "类型2",
|
|
|
|
+ value: "2",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+];
|
|
|
|
+
|
|
|
|
+const currentProdtOption = ref({
|
|
|
|
+ total: 0,
|
|
|
|
+ page: 1,
|
|
|
|
+ limit: 10,
|
|
|
|
+ pageSizes: [10, 20, 30, 40, 50, 100],
|
|
|
|
+});
|
|
|
|
+// --------------------------------------------
|
|
|
|
+const statProductTypeData = ref([
|
|
|
|
+ {
|
|
|
|
+ key: "id",
|
|
|
|
+ label: "产品类型",
|
|
|
|
+ children: [
|
|
|
|
+ {
|
|
|
|
+ key: "productType1",
|
|
|
|
+ label: "类型1",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ key: "productType2",
|
|
|
|
+ label: "类型2",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+]);
|
|
|
|
+const selectedRows = ref([]); // 存储选中的行数据
|
|
|
|
+
|
|
|
|
+const handleSelectionChange = (rows) => {
|
|
|
|
+ selectedRows.value = rows; // 更新选中的行数据
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const treeData = ref([]); // 存储转换后的 el-tree 数据
|
|
|
|
+const handleConfirm = () => {
|
|
|
|
+ const map = {};
|
|
|
|
+ const tree = [];
|
|
|
|
|
|
|
|
+ selectedRows.value.forEach((row) => {
|
|
|
|
+ const { productName, batchNo } = row;
|
|
|
|
+
|
|
|
|
+ // 如果父级节点不存在,创建父级节点
|
|
|
|
+ if (!map[productName]) {
|
|
|
|
+ const parentNode = {
|
|
|
|
+ label: productName, // 父级名称
|
|
|
|
+ key: productName, // 父级唯一标识
|
|
|
|
+ children: [], // 子级数组
|
|
|
|
+ };
|
|
|
|
+ map[productName] = parentNode;
|
|
|
|
+ tree.push(parentNode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 添加子级节点
|
|
|
|
+ map[productName].children.push({
|
|
|
|
+ label: batchNo, // 子级名称
|
|
|
|
+ key: batchNo, // 子级唯一标识
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ treeData.value = tree; // 更新 el-tree 数据源
|
|
|
|
+ dialogVisible.value = false; // 关闭对话框
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const getTableDataSearch = () => {
|
|
|
|
+ if (treeData.value.length === 0) {
|
|
|
|
+ ElMessage.warning("请选择产品");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 提取 treeData 中的 productName 和 batchNo
|
|
|
|
+ const selectedProductMap = {};
|
|
|
|
+ treeData.value.forEach((parent) => {
|
|
|
|
+ selectedProductMap[parent.label] = parent.children.map(
|
|
|
|
+ (child) => child.label
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 筛选 tableProdtData 中符合条件的数据
|
|
|
|
+ const filteredData = tableProdtData.value.filter((item) => {
|
|
|
|
+ const productNameMatches = selectedProductMap[item.productName];
|
|
|
|
+ return productNameMatches && productNameMatches.includes(item.batchNo);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 更新表格数据
|
|
|
|
+ tableData.value = filteredData;
|
|
|
|
+};
|
|
//-------------------
|
|
//-------------------
|
|
|
|
|
|
const checkedKeys = computed(() => {
|
|
const checkedKeys = computed(() => {
|