|
@@ -1,87 +1,87 @@
|
|
|
const currency = require("../../../../../utils/currency"),
|
|
const currency = require("../../../../../utils/currency"),
|
|
|
- CNY = value => currency(value, {
|
|
|
|
|
- symbol: "¥",
|
|
|
|
|
- precision: 2
|
|
|
|
|
- }).format();
|
|
|
|
|
|
|
+ CNY = value => currency(value, {
|
|
|
|
|
+ symbol: "¥",
|
|
|
|
|
+ precision: 2
|
|
|
|
|
+ }).format();
|
|
|
Component({
|
|
Component({
|
|
|
- properties: {
|
|
|
|
|
- list: Array,
|
|
|
|
|
- deleteItem: Function,
|
|
|
|
|
- changeQueue: Function, //修改队列
|
|
|
|
|
- disabled: Boolean
|
|
|
|
|
- },
|
|
|
|
|
- options: {
|
|
|
|
|
- addGlobalClass: true
|
|
|
|
|
- },
|
|
|
|
|
- methods: {
|
|
|
|
|
- /* 修改产品数量/单价 */
|
|
|
|
|
- onBlur(e) {
|
|
|
|
|
- let {
|
|
|
|
|
- name,
|
|
|
|
|
- index
|
|
|
|
|
- } = e.currentTarget.dataset;
|
|
|
|
|
- let item = this.data.list[index];
|
|
|
|
|
- if (e.detail.value <= 0) {
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- title: '非法数值',
|
|
|
|
|
- icon: "none",
|
|
|
|
|
- mask: true
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- if (item[name] == e.detail.value) return;
|
|
|
|
|
- // orderminqty 起订量
|
|
|
|
|
- // orderaddqty 增量
|
|
|
|
|
- let v = e.detail.value - 0;
|
|
|
|
|
- //处理起订量和增量
|
|
|
|
|
- if (name == 'qty') {
|
|
|
|
|
- if (v < item.orderminqty) {
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- title: `输入数量小于起订量${item.orderminqty}`,
|
|
|
|
|
- icon: "none",
|
|
|
|
|
- mask: true
|
|
|
|
|
- });
|
|
|
|
|
- item.qty = item.orderminqty;
|
|
|
|
|
- } else if (item.orderminqty < v) {
|
|
|
|
|
- var currencyRounding = value => currency(value, {
|
|
|
|
|
- increment: item.orderaddqty
|
|
|
|
|
- });
|
|
|
|
|
- item.qty = currency(currencyRounding(currency(v).subtract(item.orderminqty)).format()).add(item.orderminqty).value;
|
|
|
|
|
- if (item.qty != v) wx.showToast({
|
|
|
|
|
- title: `输入数量不符合增减量规则,已为您取最接近的值`,
|
|
|
|
|
- icon: "none",
|
|
|
|
|
- mask: true
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- item.qty = v;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- item[name] = v;
|
|
|
|
|
- }
|
|
|
|
|
- if (name == "price") item[name] = item[name] > item.marketprice ? item[name] = item.marketprice : (item[name] - 0).toFixed(2) - 0;
|
|
|
|
|
- item.amount = CNY(currency(item.price).multiply(item.qty));
|
|
|
|
|
- let obj = {};
|
|
|
|
|
- ["sa_project_itemsid", "itemid", "qty", "remarks", "marketprice", "price"].forEach(v => obj[v] = item[v]);
|
|
|
|
|
- this.triggerEvent("changeQueue", obj)
|
|
|
|
|
- }
|
|
|
|
|
- this.setData({
|
|
|
|
|
- list: this.data.list
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ list: Array,
|
|
|
|
|
+ deleteItem: Function,
|
|
|
|
|
+ changeQueue: Function, //修改队列
|
|
|
|
|
+ disabled: Boolean
|
|
|
},
|
|
},
|
|
|
- deleteProduct(e) {
|
|
|
|
|
- const {
|
|
|
|
|
- sa_project_itemsid,
|
|
|
|
|
- itemname
|
|
|
|
|
- } = e.currentTarget.dataset.item,
|
|
|
|
|
- that = this;
|
|
|
|
|
- wx.showModal({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- content: `是否确认删除“${itemname}”?`,
|
|
|
|
|
- complete: ({
|
|
|
|
|
- confirm
|
|
|
|
|
- }) => {
|
|
|
|
|
- if (confirm) that.triggerEvent("deleteItem", [sa_project_itemsid]);
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ options: {
|
|
|
|
|
+ addGlobalClass: true
|
|
|
},
|
|
},
|
|
|
- }
|
|
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ /* 修改产品数量/单价 */
|
|
|
|
|
+ onBlur(e) {
|
|
|
|
|
+ let {
|
|
|
|
|
+ name,
|
|
|
|
|
+ index
|
|
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
|
|
+ let item = this.data.list[index];
|
|
|
|
|
+ if (e.detail.value <= 0) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '非法数值',
|
|
|
|
|
+ icon: "none",
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (item[name] == e.detail.value) return;
|
|
|
|
|
+ // orderminqty 起订量
|
|
|
|
|
+ // orderaddqty 增量
|
|
|
|
|
+ let v = e.detail.value - 0;
|
|
|
|
|
+ //处理起订量和增量
|
|
|
|
|
+ if (name == 'qty') {
|
|
|
|
|
+ if (v < item.orderminqty) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: `输入数量小于起订量${item.orderminqty}`,
|
|
|
|
|
+ icon: "none",
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ item.qty = item.orderminqty;
|
|
|
|
|
+ } else if (item.orderminqty < v) {
|
|
|
|
|
+ var currencyRounding = value => currency(value, {
|
|
|
|
|
+ increment: item.orderaddqty
|
|
|
|
|
+ });
|
|
|
|
|
+ item.qty = currency(currencyRounding(currency(v).subtract(item.orderminqty)).format()).add(item.orderminqty).value;
|
|
|
|
|
+ if (item.qty != v) wx.showToast({
|
|
|
|
|
+ title: `输入数量不符合增减量规则,已为您取最接近的值`,
|
|
|
|
|
+ icon: "none",
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.qty = v;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item[name] = v;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (name == "price") item[name] = (item[name] - 0).toFixed(2) - 0;
|
|
|
|
|
+ item.amount = CNY(currency(item.price).multiply(item.qty));
|
|
|
|
|
+ let obj = {};
|
|
|
|
|
+ ["sa_project_itemsid", "itemid", "qty", "remarks", "marketprice", "price"].forEach(v => obj[v] = item[v]);
|
|
|
|
|
+ this.triggerEvent("changeQueue", obj)
|
|
|
|
|
+ }
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ list: this.data.list
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ deleteProduct(e) {
|
|
|
|
|
+ const {
|
|
|
|
|
+ sa_project_itemsid,
|
|
|
|
|
+ itemname
|
|
|
|
|
+ } = e.currentTarget.dataset.item,
|
|
|
|
|
+ that = this;
|
|
|
|
|
+ wx.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ content: `是否确认删除“${itemname}”?`,
|
|
|
|
|
+ complete: ({
|
|
|
|
|
+ confirm
|
|
|
|
|
+ }) => {
|
|
|
|
|
+ if (confirm) that.triggerEvent("deleteItem", [sa_project_itemsid]);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|