更新:细节优化

This commit is contained in:
磷叶 2025-02-18 17:13:06 +08:00
parent 9a30368b74
commit 7585a1c284
9 changed files with 168 additions and 62 deletions

View File

@ -280,3 +280,16 @@ aside {
justify-content: flex-end; /* 使用标准值 */
}
}
.table-form.el-table {
.cell {
padding-left: 0px;
padding-right: 0px;
}
}
.table-form.el-table th.el-table__cell > .cell {
padding-left: 0px;
padding-right: 0px;
}

View File

@ -1,5 +1,6 @@
<template>
<el-select
v-loading="loading"
v-model="selectedValue"
filterable
remote
@ -9,6 +10,7 @@
:loading="loading"
@change="handleChange"
@focus="handleFocus"
:class="{ 'empty-select': value == null }"
>
<el-option
v-for="item in options"
@ -17,12 +19,12 @@
:value="item.priceId"
>
<span style="float: left">
{{ item.name | dv}}
{{ item.name | dv}} ({{ item.price | dv }})
<dict-tag :value="item.status" :options="dict.type.price_status" size="mini"/>
</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.code | dv}}</span>
</el-option>
<el-option v-if="options.length === 0 && !loading" style="height: 0px" disabled label="" :value="null"/>
<el-option v-if="value == null && options.length == 0" disabled label="请检查" :value="null"/>
<div style="text-align: center; color: #8492a6; font-size: 13px">
{{ total }}条数据
</div>
@ -51,6 +53,10 @@ export default {
type: String,
default: null,
},
price: {
type: Number,
default: null,
},
query: {
type: Object,
default: () => ({}),
@ -81,7 +87,7 @@ export default {
},
label() {
return (item) => {
return item.name + (item.code ? '(' + item.code + ')' : '');
return item.price == null ? '--' : item.price;
}
}
},
@ -89,14 +95,19 @@ export default {
value(nv, ov ) {
let obj = this.options.find(item => item.priceId == nv);
if (obj == null) {
this.options.push({priceId: nv, name: this.name, code: this.code, status: this.status});
this.total ++;
if (nv == null) {
this.options = [];
this.total = 0;
} else {
this.options.push({priceId: nv, name: this.name, code: this.code, status: this.status, price: this.price});
this.total ++;
}
}
}
},
created() {
if (this.value != null) {
this.options = [{priceId: this.value, name: this.name, code: this.code, status: this.status}]
this.options = [{priceId: this.value, name: this.name, code: this.code, status: this.status, price: this.price}]
this.total = 1;
}
},
@ -116,19 +127,41 @@ export default {
this.getOptions();
},
//
getOptions() {
async getOptions() {
this.loading = true
this.queryParams = {
...this.queryParams,
...this.query
}
listPrice(this.queryParams).then(res => {
try {
let res = await listPrice(this.queryParams);
this.options = res.rows;
this.total = res.total;
}).finally(() => {
} finally {
this.loading = false;
})
}
},
//
async getOptionsAndSelectFirst() {
await this.getOptions();
if (this.options.length > 0) {
let value = this.options[0].priceId;
this.selectedValue = value;
this.handleChange(value);
} else {
this.options = [];
this.selectedValue = null;
this.handleChange(null);
}
}
}
}
</script>
</script>
<style lang="scss">
.empty-select.el-select {
.el-input__inner {
color: red !important;
}
}
</style>

View File

@ -1,5 +1,5 @@
<template>
<el-table-column class="table-form-col" :align="align" :width="width" >
<el-table-column class="table-form-col" :header-align="align" :align="align" :width="width" >
<template #header>
<div @click="handleClickHeader">
<span :class="required ? 'required-label' : ''">{{label}}</span>

View File

@ -22,7 +22,7 @@ module.exports = {
/**
* 是否固定头部
*/
fixedHeader: false,
fixedHeader: true,
/**
* 是否显示logo

View File

@ -231,3 +231,9 @@ export function tansParams(params) {
export function blobValidate(data) {
return data.type !== 'application/json'
}
// 获取字典标签
export function getDictLabel(value, options) {
return options.filter(item => item.value === value).map(item => item.label).join(',');
}

View File

@ -14,6 +14,7 @@
<el-button slot="append" icon="el-icon-search" @click="handleSearch"></el-button>
</el-input>
<el-row type="flex" style="justify-content: flex-end;align-items: center;">
<div style="font-size: 12px; color: #999; margin-right: 10px;line-height: 1em;">显示图案:<el-switch v-model="showPattern" @change="handleChangeShowPattern" style="height: 20px" size="mini" /></div>
<div style="font-size: 12px; color: #999; margin-right: 10px;line-height: 1em;">自动汇总良品:<el-switch v-model="autoSumNum" style="height: 20px" size="mini" /></div>
<el-button type="text" size="mini" :disabled="rows.length === 0" @click="handleBatchEditUserProduct" icon="el-icon-edit">修改所选员工产量</el-button>
<el-button type="text" size="mini" :disabled="rows.length === 0" @click="handleCopy" icon="el-icon-document-copy">复制所选工序</el-button>
@ -32,18 +33,18 @@
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" align="center"/>
<el-table-column type="index" min-width="10" align="right" label="#"/>
<table-form-col label="工序" prop-prefix="productList" prop="priceId" required :rules="rules.productList.priceId">
<price-select
slot-scope="d"
v-model="d.row.priceId"
:name="d.row.priceName"
:code="d.row.priceCode"
:status="d.row.priceStatus"
:query="priceQuery"
@change="(val) => handlePriceChange(d.row, val)"
style="width: 100%;"
/>
<el-table-column type="index" min-width="10" align="center" label="#"/>
<table-form-col label="工序名称" prop-prefix="productList" prop="priceName" :rules="rules.productList.priceName" header-icon="el-icon-edit" @click-header="handleBatchEdit('priceName')">
<el-input slot-scope="d" v-model="d.row.priceName" placeholder="请输入工序名称" @change="selectPrice(d.index)" />
</table-form-col>
<table-form-col label="类别" prop-prefix="productList" prop="priceCategory" width="80" :rules="rules.productList.priceCategory" header-icon="el-icon-edit" @click-header="handleBatchEdit('priceCategory')">
<el-input slot-scope="d" v-model="d.row.priceCategory" placeholder="请输入类别" @change="selectPrice(d.index)" />
</table-form-col>
<table-form-col label="大小" prop-prefix="productList" prop="priceSize" width="60" :rules="rules.productList.priceSize" header-icon="el-icon-edit" @click-header="handleBatchEdit('priceSize')">
<el-input slot-scope="d" v-model="d.row.priceSize" placeholder="请输入大小" @change="selectPrice(d.index)" />
</table-form-col>
<table-form-col label="图案" v-if="showPattern" prop-prefix="productList" width="100" prop="pricePattern" :rules="rules.productList.pricePattern" header-icon="el-icon-edit" @click-header="handleBatchEdit('pricePattern')">
<el-input slot-scope="d" v-model="d.row.pricePattern" placeholder="请输入图案" @change="selectPrice(d.index)" />
</table-form-col>
<table-form-col label="成品" prop-prefix="productList" prop="isEnd" :rules="rules.productList.isEnd" required width="60">
<el-checkbox slot-scope="d" v-model="d.row.isEnd"/>
@ -51,27 +52,38 @@
<!-- <table-form-col label="不良品" prop-prefix="productList" prop="defectNum">
<el-input-number slot-scope="d" v-model="d.row.defectNum" placeholder="请输入数量" :min="0" :precision="0" controls-position="right" style="width: 100%"/>
</table-form-col> -->
<table-form-col label="表面处理" prop-prefix="productList" prop="surface" :rules="rules.productList.surface" header-icon="el-icon-edit" @click-header="handleBatchEdit('surface')">
<table-form-col label="表面" width="80" prop-prefix="productList" prop="surface" :rules="rules.productList.surface" header-icon="el-icon-edit" @click-header="handleBatchEdit('surface')">
<el-select slot-scope="d" v-model="d.row.surface" placeholder="请选择表面处理" filterable clearable allow-create style="width: 100%;">
<el-option v-for="item in dict.type.surface" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</table-form-col>
<table-form-col label="颜色" prop-prefix="productList" prop="color" :rules="rules.productList.color" header-icon="el-icon-edit" @click-header="handleBatchEdit('color')">
<table-form-col label="颜色" width="120" prop-prefix="productList" prop="color" :rules="rules.productList.color" header-icon="el-icon-edit" @click-header="handleBatchEdit('color')">
<el-select slot-scope="d" v-model="d.row.color" placeholder="请选择颜色" filterable clearable allow-create style="width: 100%;">
<el-option v-for="item in dict.type.color_code" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</table-form-col>
<table-form-col label="良品" prop-prefix="productList" prop="num" required :rules="rules.productList.num" header-icon="el-icon-edit" @click-header="handleBatchEdit('num')">
<table-form-col label="良品" prop-prefix="productList" width="100" prop="num" required :rules="rules.productList.num" header-icon="el-icon-edit" @click-header="handleBatchEdit('num')">
<el-input slot-scope="d" v-model="d.row.num" placeholder="请输入数量">
<template #append>
<template #suffix>
{{d.row.priceUnit | dv}}
</template>
</el-input>
</table-form-col>
<table-form-col label="单价" prop-prefix="productList" prop="pricePrice" align="right" width="80" :rules="rules.productList.pricePrice">
<span slot-scope="d" style="font-size: 12px;">{{d.row.pricePrice | dv}}</span>
<table-form-col label="单价" prop-prefix="productList" width="100" prop="priceId" required :rules="rules.productList.priceId">
<price-select
slot-scope="d"
v-model="d.row.priceId"
:name="d.row.priceName"
:code="d.row.priceCode"
:status="d.row.priceStatus"
:price="d.row.pricePrice"
:query="priceQuery(d.row)"
@change="(val) => handlePriceChange(d.row, val)"
style="width: 100%;"
:ref="`priceSelect${d.index}`"
/>
</table-form-col>
<table-form-col label="详细" prop-prefix="productList" prop="pricePrice" align="right" width="80" :rules="rules.productList.pricePrice">
<table-form-col label="详细" prop-prefix="productList" prop="pricePrice" align="right" width="60" :rules="rules.productList.pricePrice">
<div slot-scope="d" @click="handleDetail(d.row)">
<div style="font-size: 12px;">员工:{{d.row.userProdList.length}}</div>
<div style="font-size: 12px;" v-if="d.row.orderProdList.length > 0">订单:{{d.row.orderProdList.length}}</div>
@ -192,45 +204,63 @@ export default {
surface: '表面处理',
color: '颜色',
num: '良品',
priceCategory: '类别',
priceSize: '大小',
pricePattern: '图案',
priceName: '工序',
},
autoSumNum: true, //
showPattern: false, //
}
},
computed: {
priceQuery() {
return {
deptId: this.form.deptId,
statusList: PriceStatus.canUse(),
disabled: false,
excludePriceIds: this.form.productList.map(item => item.priceId)
return (row) => {
return {
deptId: this.form.deptId,
statusList: PriceStatus.canUse(),
disabled: false,
eqCategory: row.priceCategory,
eqSize: row.priceSize,
eqPattern: row.pricePattern,
name: row.priceName,
}
}
}
},
created() {
this.handleSearch();
this.showPattern = localStorage.getItem("report_show_pattern") == "true";
},
methods: {
handleChangeShowPattern(val) {
localStorage.setItem("report_show_pattern", val);
},
//
selectPrice(index) {
this.$refs[`priceSelect${index}`].getOptionsAndSelectFirst();
},
handleDetail(row) {
//
this.$refs.table.toggleRowExpansion(row);
},
handlePriceChange(row, val) {
row.priceSubName = val?.subName;
row.priceSpec = val?.spec;
row.pricePrice = val?.price;
row.priceUnit = val?.unit;
row.priceClassify = val?.classify;
row.priceQuantityNumerator = val?.quantityNumerator;
row.priceQuantityDenominator = val?.quantityDenominator;
row.priceCode = val?.code;
row.priceStatus = val?.status;
if (val == null) {
return;
}
row.priceCategory = val.category;
row.priceSize = val.size;
row.priceName = val.name;
row.priceSubName = val.subName;
row.pricePattern = val.pattern;
row.priceSpec = val.spec;
row.pricePrice = val.price;
row.priceUnit = val.unit;
row.priceClassify = val.classify;
row.priceQuantityNumerator = val.quantityNumerator;
row.priceQuantityDenominator = val.quantityDenominator;
row.priceCode = val.code;
row.priceStatus = val.status;
},
//
handleChangeUserNum(row) {
@ -316,14 +346,26 @@ export default {
return;
}
let fieldName = this.fieldMap[prop];
this.$prompt(`请输入要批量修改的${fieldName}`, '提示', {
this.$prompt(`请输入要批量修改的${fieldName}`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputValue: '',
inputPlaceholder: `请输入${fieldName}`,
inputPlaceholder: `请输入${fieldName}`,
}).then(({ value }) => {
this.rows.forEach(row => {
let isEditPrice = ['priceCategory', 'priceSize', 'pricePattern', 'priceName'].includes(prop);
for (let i = 0; i < this.rows.length; i++) {
let row = this.rows[i];
row[prop] = value;
}
this.$nextTick(() => {
if (isEditPrice) {
for (let i = 0; i < this.rows.length; i++) {
let index = this.form.productList.indexOf(this.rows[i]);
if (index != -1) {
this.selectPrice(index);
}
}
}
})
this.$message.success(`批量编辑成功,一共修改了${this.rows.length}行数据`);
this.handleSearch();

View File

@ -50,6 +50,7 @@
import TableFormCol from '@/components/TableFormCol/index.vue'
import UserNewDrawer from '@/components/Business/User/UserNewDrawer.vue'
import {listUserWithShift} from "@/api/system/user";
import { notNullDecimal } from "@/utils/index";
export default {
name: "ReportProductUserList",
components: {TableFormCol, UserNewDrawer },
@ -86,13 +87,14 @@ export default {
}
},
computed: {
//
userQuery() {
return {
shiftDate: this.form.reportDate,
targetDeptId: this.form.deptId,
excludeUserIds: this.value.map(item => item.userId),
}
}
},
},
methods: {
listUserWithShift,

View File

@ -131,16 +131,6 @@ export default {
},
computed: {
...mapGetters(['deptId']),
//
// totalPrice() {
// let total = new Decimal(0);
// if (this.form != null && !isEmpty(this.form.productList)) {
// this.form.productList.forEach(item => {
// total = total.plus(notNullDecimal(item.totalAmount));
// })
// }
// return total;
// },
//
title() {
if (this.form.reportId == null) {
@ -247,9 +237,14 @@ export default {
})
},
submitForm(submit) {
// this.form.totalAmount = this.totalPrice;
this.$refs["form"].validate(valid => {
if (valid) {
let error = this.checkForm();
if (error != null) {
this.$message.error(error);
return;
}
this.$confirm(`确认${submit ? '保存并提交' : '保存'}当前报表?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -291,6 +286,21 @@ export default {
remark: null,
productList: []
};
},
checkForm() {
//
for(let index = 0; index < this.form.productList.length; index++) {
let item = this.form.productList[index];
let userNum = item.userProdList.reduce((acc, curr) => notNullDecimal(acc).plus(notNullDecimal(curr.num)).toNumber(), 0);
if (userNum > item.num) {
return `${index + 1}行工序校验失败:员工产量【${userNum}】不能大于工序产量【${item.num}`;
}
let orderNum = item.orderProdList.reduce((acc, curr) => notNullDecimal(acc).plus(notNullDecimal(curr.num)).toNumber(), 0);
if (orderNum > item.num) {
return `${index + 1}行工序校验失败:订单产量【${orderNum}】不能大于工序产量【${item.num}`;
}
}
return null;
}
}
}

View File

@ -292,7 +292,7 @@ export default {
{key: 'surface', visible: false, label: '表面处理', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'color', visible: false, label: '颜色', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'num', visible: true, label: '良品', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'defectNum', visible: true, label: '不良品', minWidth: null, sortable: true, overflow: false, align: 'center', width: "100"},
{key: 'defectNum', visible: false, label: '不良品', minWidth: null, sortable: true, overflow: false, align: 'center', width: "100"},
{key: 'priceUnit', visible: true, label: '单位', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'pricePrice', visible: true, label: '单价', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'totalAmount', visible: true, label: '总价', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},