123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- <template>
- <div class="tenant">
- <!-- <Banner /> -->
- <div class="content">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- highlight-current-row
- :selectConfig="selectConfig"
- :table-events="{
- //element talbe事件都能传
- select: selectRow,
- }"
- :action-list="[
- {
- text: '质检',
- disabled: selectData.length === 0,
- action: () => start(20),
- },
- ]"
- @get-list="getList"
- >
- <template #fileSlot="{ item }">
- <div
- style="cursor: pointer; color: #409eff"
- @click="handleClickFile(item)"
- >
- {{ item.fileName }}
- </div>
- </template>
- </byTable>
- </div>
- <el-dialog
- title="到货质检"
- v-model="dialogVisible"
- width="800"
- v-loading="loading"
- >
- <el-form
- :model="formData.data"
- :rules="rules"
- ref="formDom"
- label-position="top"
- >
- <div style="margin-bottom: 10px; font-size: 14px">基础信息</div>
- <el-row>
- <el-col :span="8">
- <el-form-item label="供应商" prop="supplyId">
- <el-select
- v-model="formData.data.supplyId"
- placeholder="请选择"
- style="width: 100%"
- disabled
- >
- <el-option
- v-for="item in supplierData"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="6">
- <el-form-item label="采购单号" prop="code">
- <el-input
- v-model="formData.data.code"
- placeholder="请输入"
- disabled
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <div style="margin-bottom: 10px; font-size: 14px">到货明细</div>
- <el-form-item>
- <el-table :data="formData.data.qualityDetailList">
- <el-table-column
- prop="productType"
- label="货品类型"
- :formatter="(row) => (row.productType == 1 ? '产品' : '物料')"
- />
- <el-table-column prop="productCode" label="货品编码" />
- <el-table-column prop="productName" label="货品名称" />
- <el-table-column prop="productSpec" label="规格型号" />
- <el-table-column prop="productUnit" label="单位" />
- <el-table-column prop="count" label="到货数量" />
- <el-table-column prop="sumQualityCount" label="已质检" />
- <el-table-column
- prop="qualifiedCount"
- label="质检合格"
- min-width="150"
- >
- <template #default="{ row, $index }">
- <el-form-item
- :prop="'qualityDetailList.' + $index + '.qualifiedCount'"
- :rules="rules.qualifiedCount"
- :inline-message="true"
- >
- <el-input-number
- v-model="row.qualifiedCount"
- :precision="4"
- :controls="false"
- :min="0"
- />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- prop="noQualifiedCount"
- label="质检不合格"
- min-width="150"
- >
- <template #default="{ row, $index }">
- <el-form-item
- :prop="'qualityDetailList.' + $index + '.noQualifiedCount'"
- :rules="rules.noQualifiedCount"
- :inline-message="true"
- >
- <el-input-number
- v-model="row.noQualifiedCount"
- :precision="4"
- :controls="false"
- :min="0"
- />
- </el-form-item>
- </template>
- </el-table-column>
- </el-table>
- </el-form-item>
- </el-form>
- <template #footer>
- <el-button @click="dialogVisible = false" size="large">取 消</el-button>
- <el-button
- type="primary"
- @click="submitForm()"
- size="large"
- :loading="submitLoading"
- >
- 确 定
- </el-button>
- </template>
- </el-dialog>
- </div>
- </template>
-
- <script setup>
- /* eslint-disable vue/no-unused-components */
- import { ElMessage, ElMessageBox } from "element-plus";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import FileUpload from "@/components/FileUpload/index";
- import { computed, defineComponent, ref, watch } from "vue";
- import { getToken } from "@/utils/auth";
- const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传文件服务器地址
- const headers = ref({ Authorization: "Bearer " + getToken() });
- const uploadData = ref({});
- const loading = ref(false);
- const submitLoading = ref(false);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 3,
- pageNum: 1,
- pageSize: 10,
- },
- });
- let dialogVisible = ref(false);
- let modalType = ref("add");
- let fileList = ref([]);
- let rules = ref({
- name: [{ required: true, message: "请输入供应商名称", trigger: "blur" }],
- qualifiedCount: [
- { required: true, message: "请输入质检合格数量", trigger: "blur" },
- ],
- noQualifiedCount: [
- { required: true, message: "请输入质检不合格数量", trigger: "blur" },
- ],
- });
- const { proxy } = getCurrentInstance();
- const selectConfig = reactive([
- {
- label: "质检状态",
- prop: "status",
- data: [
- {
- label: "未质检",
- value: "0",
- },
- {
- label: "部分质检",
- value: "10",
- },
- {
- label: "已质检",
- value: "20",
- },
- ],
- },
- ]);
- const config = computed(() => {
- return [
- {
- type: "selection",
- attrs: {
- checkAtt: "isCheck",
- },
- },
- {
- attrs: {
- label: "采购单号",
- prop: "code",
- },
- },
- {
- attrs: {
- label: "供应商",
- prop: "supplyName",
- },
- },
- {
- attrs: {
- label: "物流/快递公司",
- prop: "productType",
- },
- },
- {
- attrs: {
- label: "物流/快递单号",
- prop: "productCode",
- },
- },
- {
- attrs: {
- label: "采购员",
- prop: "productName",
- },
- },
- {
- attrs: {
- label: "采购时间",
- prop: "productSpec",
- },
- },
- {
- attrs: {
- label: "质检状态",
- prop: "productUnit",
- },
- },
- {
- attrs: {
- label: "操作",
- width: "100",
- align: "right",
- },
- // 渲染 el-button,一般用在最后一列。
- renderHTML(row) {
- return [
- row.status == 20
- ? {
- attrs: {
- label: "质检",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- selectDataOne.value = [row];
- start(10);
- },
- }
- : {},
- ];
- },
- },
- ];
- });
- let formData = reactive({
- data: {},
- });
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const formConfig = computed(() => {});
- const formDom = ref(null);
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy
- .post("/arrivalDetail/page", sourceList.value.pagination)
- .then((message) => {
- message.rows.forEach((x) => {
- if (x.status < 20) {
- x.isCheck = true;
- } else {
- x.isCheck = false;
- }
- });
- sourceList.value.data = message.rows;
- sourceList.value.pagination.total = message.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- const submitForm = () => {
- formDom.value.validate((valid) => {
- const list = formData.data.qualityDetailList;
- for (let i = 0; i < list.length; i++) {
- const e = list[i];
- if (!(e.qualifiedCount + e.noQualifiedCount > 0)) {
- return ElMessage({
- message: "质检数量不能为0!",
- type: "info",
- });
- }
- if (
- e.qualifiedCount + e.noQualifiedCount + Number(e.sumQualityCount) >
- Number(e.count)
- ) {
- return ElMessage({
- message: "质检数量不能大于到货数量!",
- type: "info",
- });
- }
- }
- submitLoading.value = true;
- proxy.post("/quality/" + modalType.value, formData.data).then(
- (res) => {
- ElMessage({
- message: "质检成功",
- type: "success",
- });
- dialogVisible.value = false;
- submitLoading.value = false;
- getList();
- },
- (err) => {
- submitLoading.value = false;
- }
- );
- });
- };
- const getDtl = (row) => {
- modalType.value = "edit";
- dialogVisible.value = true;
- // proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
- // fileList.value = [
- // {
- // id: "",
- // fileName: res.fileName,
- // path: "",
- // },
- // ];
- // formData.data = res;
- // dialogVisible.value = true;
- // });
- };
- getList();
- const selectData = ref([]);
- const selectDataOne = ref([]);
- const selectRow = (data) => {
- selectData.value = data;
- };
- const start = (type) => {
- modalType.value = "add";
- let ids = [];
- let row = {};
- if (type === 10) {
- row = selectDataOne.value[0];
- ids = selectDataOne.value.map((x) => x.id);
- } else if (type === 20) {
- ids = selectData.value.map((x) => x.id);
- row = selectData.value[0];
- }
- proxy.post("/arrivalDetail/detail", { ids }).then((res) => {
- formData.data = {
- arrivalId: row.arrivalId,
- supplyId: row.supplyId,
- supplyName: row.supplyName,
- code: row.code,
- qualityDetailList: res.map((x) => ({
- ...x,
- arrivalDetailId: x.id,
- qualifiedCount: 0,
- noQualifiedCount: 0,
- })),
- };
- dialogVisible.value = true;
- });
- };
- watch(selectData, (newVal, oldVal) => {
- if (newVal.length == 0) {
- sourceList.value.data.forEach((x) => {
- if (x.status < 20) {
- x.isCheck = true;
- } else {
- x.isCheck = false;
- }
- });
- } else if (newVal.length == 1) {
- const current = newVal[0];
- sourceList.value.data.forEach((x) => {
- if (x.arrivalId !== current.arrivalId || x.status == 20) {
- x.isCheck = false;
- }
- });
- }
- });
- onMounted(() => {});
- </script>
-
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- .el-checkbox {
- display: none;
- }
- </style>
|