|
@@ -50,6 +50,14 @@
|
|
|
>
|
|
>
|
|
|
批量删除
|
|
批量删除
|
|
|
</el-button>
|
|
</el-button>
|
|
|
|
|
+ <!-- 批量设置发货数量:仅开发环境提供 -->
|
|
|
|
|
+ <setAllCountPrice
|
|
|
|
|
+ :disabled="!selection.length || sourceType == 4"
|
|
|
|
|
+ :show-price="false"
|
|
|
|
|
+ count-title="发货数量"
|
|
|
|
|
+ button-text="批量设置发货数量"
|
|
|
|
|
+ @success="setAllSendCountChange"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -512,6 +520,8 @@
|
|
|
import getDynamicsColumns from '@/mixins/getDynamicsColumns';
|
|
import getDynamicsColumns from '@/mixins/getDynamicsColumns';
|
|
|
import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
|
|
import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
|
|
|
import BIZproductList from '@/BIZComponents/product-list.vue';
|
|
import BIZproductList from '@/BIZComponents/product-list.vue';
|
|
|
|
|
+ import setAllCountPrice from '@/BIZComponents/setAllCountPrice.vue'; //批量设置发货数量
|
|
|
|
|
+ import { IS_DEV } from '@/config/setting'; //是否开发环境
|
|
|
import tabMixins from '@/mixins/tableColumnsMixin';
|
|
import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
import { levelList, pricingWayList, lbjtList } from '@/enum/dict.js';
|
|
import { levelList, pricingWayList, lbjtList } from '@/enum/dict.js';
|
|
|
import { changeCount, formatPrice } from '@/BIZComponents/setProduct.js';
|
|
import { changeCount, formatPrice } from '@/BIZComponents/setProduct.js';
|
|
@@ -564,7 +574,8 @@
|
|
|
productListNew,
|
|
productListNew,
|
|
|
stockLedgerDialog,
|
|
stockLedgerDialog,
|
|
|
selectStockLedgerDialog,
|
|
selectStockLedgerDialog,
|
|
|
- BIZproductList
|
|
|
|
|
|
|
+ BIZproductList,
|
|
|
|
|
+ setAllCountPrice
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
const defaultForm = {
|
|
const defaultForm = {
|
|
@@ -1948,6 +1959,101 @@
|
|
|
.catch(() => {});
|
|
.catch(() => {});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ // 批量设置发货数量:只作用于勾选的行,仅开发环境可用
|
|
|
|
|
+ setAllSendCountChange({ count }) {
|
|
|
|
|
+ if (!IS_DEV) return;
|
|
|
|
|
+ if (count === undefined || count === null || count === '') {
|
|
|
|
|
+ return this.$message.warning('请输入发货数量');
|
|
|
|
|
+ }
|
|
|
|
|
+ const indexS = this.getSelectedIndexes();
|
|
|
|
|
+ if (!indexS.length) {
|
|
|
|
|
+ return this.$message.warning('请先勾选需要设置的行');
|
|
|
|
|
+ }
|
|
|
|
|
+ const countObj = {
|
|
|
|
|
+ countKey: 'saleCount',
|
|
|
|
|
+ unitKey: 'saleUnit',
|
|
|
|
|
+ unitIdKey: 'saleUnitId'
|
|
|
|
|
+ };
|
|
|
|
|
+ // changeCount 会返回新对象,这里只把算出来的字段写回原行对象,
|
|
|
|
|
+ // 保持行引用不变,否则勾选状态(selection 存的是行引用)会与表格失联
|
|
|
|
|
+ const calcFields = [
|
|
|
|
|
+ 'totalCount',
|
|
|
|
|
+ 'totalWeight',
|
|
|
|
|
+ 'singleWeight',
|
|
|
|
|
+ 'saleUnit',
|
|
|
|
|
+ 'discountSinglePrice',
|
|
|
|
|
+ 'totalPrice',
|
|
|
|
|
+ 'discountTotalPrice'
|
|
|
|
|
+ ];
|
|
|
|
|
+ const exceedItems = [];
|
|
|
|
|
+ indexS.forEach((i) => {
|
|
|
|
|
+ const row = this.form.datasource[i];
|
|
|
|
|
+ if (!row) return;
|
|
|
|
|
+ this.$set(row, 'saleCount', count);
|
|
|
|
|
+ const next = changeCount(row, countObj, false);
|
|
|
|
|
+ calcFields.forEach((key) => {
|
|
|
|
|
+ if (next[key] !== undefined) {
|
|
|
|
|
+ this.$set(row, key, next[key]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 发货总重 / 增重总重:与单行 changeCount 逻辑保持一致
|
|
|
|
|
+ this.$set(row, 'sendTotalWeight', row.totalWeight);
|
|
|
|
|
+ const receiveTotalWeight = Number(row.receiveTotalWeight) || 0;
|
|
|
|
|
+ const sendTotalWeight = Number(row.sendTotalWeight) || 0;
|
|
|
|
|
+ if (sendTotalWeight) {
|
|
|
|
|
+ const increaseTotalWeight = sendTotalWeight - receiveTotalWeight;
|
|
|
|
|
+ this.$set(row, 'increaseTotalWeight', increaseTotalWeight.toFixed(4));
|
|
|
|
|
+ if (row.pricingWay == 3) {
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ row,
|
|
|
|
|
+ 'totalPrice',
|
|
|
|
|
+ (increaseTotalWeight * row.singlePrice).toFixed(2)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 不含税单价
|
|
|
|
|
+ this.getNotaxSinglePrice(i);
|
|
|
|
|
+ // 客户环境 4:按模数换算发货块数
|
|
|
|
|
+ if (this.clientEnvironmentId == 4) {
|
|
|
|
|
+ this.tableHandleKeyUp(row, i, 'sum');
|
|
|
|
|
+ }
|
|
|
|
|
+ // 超过订单剩余数量的行先提示,提交时仍会被拦截
|
|
|
|
|
+ const remainingCount = Number(row.notGenerateSendCount) || 0;
|
|
|
|
|
+ if (remainingCount && Number(row.totalCount) > remainingCount) {
|
|
|
|
|
+ exceedItems.push(row.productCode || row.productName);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ this.$message.success(`已设置 ${indexS.length} 行的发货数量`);
|
|
|
|
|
+ if (exceedItems.length) {
|
|
|
|
|
+ this.$message.warning(
|
|
|
|
|
+ `${exceedItems.join('、')} 的发货数量大于订单剩余数量,请提交前调整`
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ // datasource 变化会触发表格 reload,reload 会清空勾选,
|
|
|
|
|
+ // 这里把本次设置的行重新勾上,方便连续设置不同的数量
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ const table = this.$refs.table;
|
|
|
|
|
+ if (!table || !table.toggleRowSelection) return;
|
|
|
|
|
+ indexS.forEach((i) => {
|
|
|
|
|
+ const row = this.form.datasource[i];
|
|
|
|
|
+ if (row) {
|
|
|
|
|
+ table.toggleRowSelection(row, true);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ // 勾选行在数据源中的下标:按 row-key 匹配,不依赖 key 与下标一一对应
|
|
|
|
|
+ getSelectedIndexes() {
|
|
|
|
|
+ const keys = new Set(this.selection.map((item) => item.key));
|
|
|
|
|
+ const indexS = [];
|
|
|
|
|
+ this.form.datasource.forEach((row, index) => {
|
|
|
|
|
+ if (keys.has(row.key)) {
|
|
|
|
|
+ indexS.push(index);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return indexS;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
// 重新排序
|
|
// 重新排序
|
|
|
setSort() {
|
|
setSort() {
|
|
|
this.form.datasource.forEach((n, index) => {
|
|
this.form.datasource.forEach((n, index) => {
|