+
加载中...
-
-
@@ -126,11 +151,15 @@ import { isEmpty } from '@/utils/index'
import ReportProductUserList from '@/views/yh/report/edit-v2/components/ReportProductUserList.vue'
import ReportProductOrderList from '@/views/yh/report/edit-v2/components/ReportProductOrderList.vue'
import UserProductBatchDialog from '@/views/yh/report/edit-v2/components/UserProductBatchDialog.vue'
+import { IncomeMode, PriceStatus } from '@/utils/constants'
+import { notNullDecimal } from '@/utils/index'
+import Decimal from 'decimal.js'
+import PriceSelect from '@/components/Business/Price/PriceSelect.vue'
export default {
name: "ReportProductList",
- dicts: ['price_type'],
- components: { HoverShow, BooleanTag, TableFormCol, ReportProductUserList, ReportProductOrderList, UserProductBatchDialog},
+ dicts: ['price_type', 'surface', 'color_code'],
+ components: { HoverShow, BooleanTag, TableFormCol, ReportProductUserList, ReportProductOrderList, UserProductBatchDialog, PriceSelect},
props: {
form: {
type: Object,
@@ -140,7 +169,12 @@ export default {
},
rules: {
type: Object,
- default: () => ({})
+ default: () => ({
+ productList: {
+ userProdList: {},
+ orderProdList: {},
+ }
+ })
}
},
data() {
@@ -152,9 +186,122 @@ export default {
searchKey: '', // 搜索关键字
filteredProductList: [], // 过滤后的工序列表
showUserEditDialog: false, // 批量修改员工产量弹窗
+ fieldMap: { // 字段映射
+ surface: '表面处理',
+ color: '颜色',
+ num: '良品',
+ },
+ autoSumNum: true, // 自动汇总良品
}
},
+ computed: {
+ priceQuery() {
+ return {
+ deptId: this.form.deptId,
+ status: PriceStatus.PASS, // 已审核
+ disabled: false,
+ excludePriceIds: this.form.productList.map(item => item.priceId)
+ }
+ }
+ },
+ created() {
+ this.handleSearch();
+ },
methods: {
+ handleDetail(row) {
+ // 展开行
+ this.$refs.table.toggleRowExpansion(row);
+ },
+ handlePriceChange(row, val) {
+ 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;
+ },
+ // 当用户数量发生变化时,自动汇总良品
+ handleChangeUserNum(row) {
+ if (this.autoSumNum) {
+ this.calcRowNum(row);
+ }
+ },
+ // 批量修改员工产量
+ onSubmitUserProductBatch(data) {
+ if (data == null || isEmpty(data.list)) {
+ return;
+ }
+ // 分值模式
+ if (IncomeMode.SCORE === data.mode) {
+ // 计算总分
+ let totalScore = new Decimal(0);
+ data.list.forEach(item => {
+ totalScore = totalScore.plus(notNullDecimal(item.score));
+ })
+ // 计算员工产量
+ this.rows.forEach(row => {
+ let rowNum = notNullDecimal(row.num); // 本行的总产量
+ row.userProdList = data.list.map(item => {
+ return {
+ userId: item.userId,
+ userName: item.userName,
+ userNo: item.userNo,
+ num: rowNum.mul(notNullDecimal(item.score)).div(totalScore).toNumber().toFixed(2)
+ }
+ })
+ // 若员工产量相加含有误差,则由第一个员工抹平
+ let totalNum = notNullDecimal(0);
+ if (row.userProdList != null && !isEmpty(row.userProdList)) {
+ row.userProdList.forEach(item => {
+ totalNum = notNullDecimal(item.num).add(totalNum);
+ })
+ if (totalNum.toNumber() !== rowNum.toNumber()) {
+ let subtract = rowNum.sub(totalNum); // 差值
+ row.userProdList[0].num = notNullDecimal(row.userProdList[0].num).add(subtract).toNumber();
+ }
+ }
+ })
+ }
+ // 数量模式
+ else if (IncomeMode.COUNT === data.mode) {
+ this.rows.forEach(row => {
+ // 覆盖员工产量
+ row.userProdList = data.list.map(item => {
+ return {
+ userId: item.userId,
+ userName: item.userName,
+ userNo: item.userNo,
+ num: item.num
+ }
+ })
+
+ // 若需要自动汇总良品,则计算总产量
+ if (this.autoSumNum) {
+ this.calcRowNum(row);
+ }
+ })
+ this.$message.success("批量编辑成功");
+ }
+
+ this.showUserEditDialog = false;
+ },
+ // 计算单行总产量
+ calcRowNum(row) {
+ let totalCount = notNullDecimal(0);
+ row.userProdList.forEach(item => {
+ totalCount = notNullDecimal(item.num).add(totalCount);
+ })
+ row.num = totalCount.toNumber();
+ },
// 批量修改员工产量
handleBatchEditUserProduct() {
this.showUserEditDialog = true;
@@ -162,19 +309,20 @@ export default {
// 批量编辑属性
handleBatchEdit(prop) {
if (this.rows.length === 0) {
- this.$message.warning('请先勾选要编辑的工序');
+ this.$message.warning('请先勾选要批量修改的数据行');
return;
}
- this.$prompt('请输入要编辑的属性值', '提示', {
+ let fieldName = this.fieldMap[prop];
+ this.$prompt(`请输入要批量修改的${fieldName}`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputValue: '',
- inputPlaceholder: '请输入属性值',
+ inputPlaceholder: `请输入${fieldName}`,
}).then(({ value }) => {
this.rows.forEach(row => {
row[prop] = value;
})
- this.$message.success(`批量编辑成功,一共修改了${this.rows.length}行工序`);
+ this.$message.success(`批量编辑成功,一共修改了${this.rows.length}行数据`);
this.handleSearch();
})
},
@@ -235,6 +383,18 @@ export default {
surface: null,
color: null,
sort: this.getNewSort(),
+ // vo
+ priceName: null,
+ priceCode: null,
+ priceUnit: null,
+ pricePrice: null,
+ priceCategory: null,
+ priceSize: null,
+ pricePattern: null,
+ priceSpec: null,
+ priceClassify: null,
+ priceQuantityNumerator: null,
+ priceQuantityDenominator: null,
userProdList: [],
orderProdList: [],
}
@@ -281,6 +441,25 @@ export default {
this.form.productList.splice(index, 1)
})
},
+ // 批量删除工序
+ handleBatchDel() {
+ if (this.rows.length === 0) {
+ this.$message.warning('请先勾选要删除的工序');
+ return;
+ }
+ this.$confirm('是否删除所选工序?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }).then(() => {
+ for (let i = 0; i < this.rows.length; i++) {
+ this.form.productList.splice(this.form.productList.indexOf(this.rows[i]), 1);
+ }
+ this.$message.success(`删除成功,一共删除了${this.rows.length}行工序`);
+ this.rows = [];
+ this.handleSearch();
+ });
+ },
handleSearch() {
if (!this.searchKey) {
this.filteredProductList = this.form.productList;
@@ -288,10 +467,11 @@ export default {
}
const key = this.searchKey.toLowerCase();
this.filteredProductList = this.form.productList.filter(item => {
- const priceId = (item.priceId || '').toLowerCase();
+ const priceName = (item.priceName || '').toLowerCase();
+ const priceCode = (item.priceCode || '').toLowerCase();
const surface = (item.surface || '').toLowerCase();
const color = (item.color || '').toLowerCase();
- return priceId.includes(key) || surface.includes(key) || color.includes(key);
+ return priceName.includes(key) || priceCode.includes(key) || surface.includes(key) || color.includes(key);
});
}
}
diff --git a/src/views/yh/report/edit-v2/components/ReportProductOrderList.vue b/src/views/yh/report/edit-v2/components/ReportProductOrderList.vue
index 356180f..b6f5b97 100644
--- a/src/views/yh/report/edit-v2/components/ReportProductOrderList.vue
+++ b/src/views/yh/report/edit-v2/components/ReportProductOrderList.vue
@@ -5,7 +5,9 @@
size="mini"
stripe
class="mini-table"
+ @selection-change="handleSelectionChange"
>
+
@@ -17,7 +19,7 @@
{{d.row.orderMaterialNumber | dv}}
-
+
{{prod.priceUnit | dv}}
@@ -39,10 +41,11 @@
-
@@ -50,11 +53,12 @@
diff --git a/src/views/yh/report/edit-v2/components/ReportProductUserList.vue b/src/views/yh/report/edit-v2/components/ReportProductUserList.vue
index 2795e8b..843360a 100644
--- a/src/views/yh/report/edit-v2/components/ReportProductUserList.vue
+++ b/src/views/yh/report/edit-v2/components/ReportProductUserList.vue
@@ -5,15 +5,17 @@
size="mini"
stripe
class="mini-table"
+ @selection-change="handleSelectionChange"
>
+