|
@@ -0,0 +1,161 @@
|
|
|
+<template>
|
|
|
+ <div class="mainContentBox">
|
|
|
+ <avue-crud
|
|
|
+ ref="crudRef"
|
|
|
+ v-model:search="search"
|
|
|
+ v-model="form"
|
|
|
+ :data="data"
|
|
|
+ :option="option"
|
|
|
+ v-model:page="page"
|
|
|
+ @row-save="createRow"
|
|
|
+ @row-update="updateRow"
|
|
|
+ @search-change="searchChange"
|
|
|
+ @search-reset="resetChange"
|
|
|
+ @size-change="dataList"
|
|
|
+ @current-change="dataList"
|
|
|
+ @selection-change="selectionChange"
|
|
|
+ @before-open="onBeforeOpen"
|
|
|
+ >
|
|
|
+ <template #checkBatch-form="scope">
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ gap: 20px;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="form.checkBatch"
|
|
|
+ placeholder="请输入批号"
|
|
|
+ ></el-input>
|
|
|
+ <el-button type="primary" @click="addNumbers">新增单号</el-button>
|
|
|
+ </div>
|
|
|
+ <el-table
|
|
|
+ v-show="tableData.length > 0"
|
|
|
+ :data="tableData"
|
|
|
+ style="width: 100%; margin-top: 20px"
|
|
|
+ >
|
|
|
+ <el-table-column prop="workOrderCode" label="工单编号" width="120" />
|
|
|
+ <el-table-column prop="state" label="State" width="120" />
|
|
|
+ <el-table-column prop="city" label="City" width="120" />
|
|
|
+ <el-table-column prop="zip" label="Zip" width="120" />
|
|
|
+ <el-table-column fixed="right" label="Operations" min-width="120">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="danger"
|
|
|
+ size="small"
|
|
|
+ @click.prevent="deleteTableRow(scope.$index)"
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </template>
|
|
|
+ </avue-crud>
|
|
|
+ <CommonTable
|
|
|
+ ref="productionLineRef"
|
|
|
+ :multipleRow="multipleRow"
|
|
|
+ tableTitle="选择工单"
|
|
|
+ tableType="WORK_ORDERS"
|
|
|
+ @selected-sure="onSelectedFinish"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script setup lang="ts">
|
|
|
+import { ref, getCurrentInstance } from "vue";
|
|
|
+import { useCrud } from "@/hooks/userCrud";
|
|
|
+
|
|
|
+// 传入一个url,后面不带/
|
|
|
+const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
|
|
|
+ useCrud({
|
|
|
+ src: "/api/v1/plan/batchNumber",
|
|
|
+ });
|
|
|
+const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
|
|
|
+ Methords; //增删改查
|
|
|
+const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
|
|
|
+const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
|
|
|
+
|
|
|
+const crudRef = ref(null); //crudRef.value 获取avue-crud对象
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ // console.log("crudRef", crudRef)
|
|
|
+ dataList();
|
|
|
+});
|
|
|
+
|
|
|
+const multipleRow = ref(true);
|
|
|
+const productionLineRef = ref(null);
|
|
|
+const startCreat = () => {
|
|
|
+ productionLineRef.value?.mergeOption({
|
|
|
+ selection: true,
|
|
|
+ reserveSelection: true,
|
|
|
+ });
|
|
|
+};
|
|
|
+const addNumbers = () => {
|
|
|
+ nextTick(() => {
|
|
|
+ if (productionLineRef.value) {
|
|
|
+ productionLineRef.value?.mergeOption({
|
|
|
+ selection: true,
|
|
|
+ reserveSelection: true,
|
|
|
+ });
|
|
|
+ productionLineRef.value.startSelect();
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+// 设置表格列或者其他自定义的option
|
|
|
+option.value = Object.assign(option.value, {
|
|
|
+ searchEnter: false,
|
|
|
+ selection: false,
|
|
|
+ menuWidth: 200,
|
|
|
+ border: true,
|
|
|
+ index: true,
|
|
|
+ delBtn: true,
|
|
|
+ viewBtn: false,
|
|
|
+ editBtn: false,
|
|
|
+ rowKey: "id",
|
|
|
+ column: [
|
|
|
+ {
|
|
|
+ label: "批号",
|
|
|
+ prop: "checkBatch",
|
|
|
+ search: true,
|
|
|
+ overHidden: true,
|
|
|
+ span: 24,
|
|
|
+ rules: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入工厂批号",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "创建时间",
|
|
|
+ prop: "created",
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+});
|
|
|
+
|
|
|
+const tableData = ref<any[]>([]); //选中的行
|
|
|
+const onBeforeOpen = (done) => {
|
|
|
+ tableData.value = [];
|
|
|
+ form.value.dtos = [];
|
|
|
+ done();
|
|
|
+};
|
|
|
+const onSelectedFinish = (selectedValue) => {
|
|
|
+ let toAddRow = JSON.parse(JSON.stringify(selectedValue));
|
|
|
+ let tableData_ids = tableData.value.map((item) => item.id);
|
|
|
+ toAddRow = toAddRow.filter((item) => {
|
|
|
+ return tableData_ids.indexOf(item.id) === -1;
|
|
|
+ });
|
|
|
+ tableData.value.push(...toAddRow);
|
|
|
+ form.value.dtos = tableData.value;
|
|
|
+};
|
|
|
+const deleteTableRow = (index: number) => {
|
|
|
+ tableData.value.splice(index, 1);
|
|
|
+ form.value.dtos = tableData.value;
|
|
|
+};
|
|
|
+</script>
|