|
@@ -0,0 +1,204 @@
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+ sourceData: null,
|
|
|
+ isEdit: null,
|
|
|
+ ProductList: null,
|
|
|
+ disabled: false,
|
|
|
+ loading: false
|
|
|
+ },
|
|
|
+
|
|
|
+ onLoad(options) {
|
|
|
+ this.setData({
|
|
|
+ sourceData: JSON.parse(options.item),
|
|
|
+ isEdit: options.isEdit == 'true'
|
|
|
+ })
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: options.isEdit == 'true' ? '预测报表' : '预测填报',
|
|
|
+ })
|
|
|
+ this.getList();
|
|
|
+ this.getProductList();
|
|
|
+ },
|
|
|
+ /* 提交 */
|
|
|
+ submit() {
|
|
|
+ if (this.data.disabled && this.data.loading) return;
|
|
|
+ this.setData({
|
|
|
+ loading: true
|
|
|
+ })
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220906155003,
|
|
|
+ "version": 1,
|
|
|
+ "content": {
|
|
|
+ "sa_salesforecastmodelid": this.data.sourceData.sa_salesforecastmodelid,
|
|
|
+ "sa_salesforecastbillid": this.data.sourceData.sa_salesforecastbillid,
|
|
|
+ "sa_projectid": this.data.sourceData.sa_projectid,
|
|
|
+ "itemclassinfos": this.data.list
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 获取列表 */
|
|
|
+ getList() {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220906154703,
|
|
|
+ "version": 1,
|
|
|
+ "content": {
|
|
|
+ "nocheca": true,
|
|
|
+ "sa_salesforecastbillid": this.data.sourceData.sa_salesforecastbillid,
|
|
|
+ 'pageSize': 9999,
|
|
|
+ "where": {
|
|
|
+ "condition": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("详情列表", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ for (let i = 0; i < res.data.length; i++) {
|
|
|
+ res.data[i].complete = true
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ list: res.data
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 获取产品列表 */
|
|
|
+ getProductList() {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220906154903,
|
|
|
+ "version": 1,
|
|
|
+ "content": {}
|
|
|
+ }).then(res => {
|
|
|
+ console.log("产品列表", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ ProductList: res.data
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 打开添加产品 */
|
|
|
+ addProduct() {
|
|
|
+ let list = this.data.ProductList.filter(v => !this.data.list.some(value => value.itemclassnum == v.itemclassnum))
|
|
|
+ this.selectComponent('#Product').setData({
|
|
|
+ show: true,
|
|
|
+ list
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 得到添加产品 */
|
|
|
+ getResult({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ const list = detail.map(v => {
|
|
|
+ const data = this.data.ProductList.find(value => value.itemclassnum == v);
|
|
|
+ return {
|
|
|
+ "sa_salesforecastid": 0,
|
|
|
+ "itemclassnum": data.itemclassnum,
|
|
|
+ "itemclassname": data.itemclassname,
|
|
|
+ "orderqty": 0,
|
|
|
+ "orderamount": 0,
|
|
|
+ "invoiceqty": 0,
|
|
|
+ "invoiceamount": 0,
|
|
|
+ "outqty": 0,
|
|
|
+ "outamount": 0,
|
|
|
+ "complete": false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ list: list.concat(this.data.list)
|
|
|
+ });
|
|
|
+ wx.pageScrollTo({
|
|
|
+ scrollTop: 0,
|
|
|
+ })
|
|
|
+ this.isDisabled();
|
|
|
+ },
|
|
|
+ /* 输入框改变 */
|
|
|
+ inputChange(e) {
|
|
|
+ const {
|
|
|
+ index,
|
|
|
+ name
|
|
|
+ } = e.currentTarget.dataset,
|
|
|
+ value = e.detail.value.trim();
|
|
|
+ this.setData({
|
|
|
+ [`list[${index}].${name}`]: value
|
|
|
+ })
|
|
|
+ if (['orderamount', 'outamount', 'invoiceamount'].includes(name)) {
|
|
|
+ const data = this.data.list[index];
|
|
|
+ this.setData({
|
|
|
+ [`list[${index}].complete`]: data.orderamount != "" && data.outamount != "" && data.invoiceamount != ""
|
|
|
+ })
|
|
|
+ };
|
|
|
+ this.isDisabled();
|
|
|
+ },
|
|
|
+ /* 删除产品 */
|
|
|
+ deleteProduct(e) {
|
|
|
+ const {
|
|
|
+ item
|
|
|
+ } = e.currentTarget.dataset,
|
|
|
+ that = this;
|
|
|
+ wx.showModal({
|
|
|
+ title: "提示",
|
|
|
+ content: `是否确认删除${item.itemclassname}`,
|
|
|
+ success({
|
|
|
+ confirm
|
|
|
+ }) {
|
|
|
+ if (confirm) {
|
|
|
+ if (item.sa_salesforecastid == 0) {
|
|
|
+ that.setData({
|
|
|
+ list: that.data.list.filter(v => v.itemclassnum != item.itemclassnum)
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: '删除成功',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ that.isDisabled();
|
|
|
+ } else {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220906155103,
|
|
|
+ "version": 1,
|
|
|
+ "content": {
|
|
|
+ "sa_salesforecastid": item.sa_salesforecastid,
|
|
|
+ "sa_projectid": item.sa_projectid,
|
|
|
+ "sa_salesforecastbillid": item.sa_salesforecastbillid
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ wx.showToast({
|
|
|
+ title: '删除成功',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ that.setData({
|
|
|
+ list: that.data.list.filter(v => v.itemclassnum != item.itemclassnum)
|
|
|
+ })
|
|
|
+ that.isDisabled();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 判断是否禁用保存按钮 */
|
|
|
+ isDisabled() {
|
|
|
+ console.log(123)
|
|
|
+ let count = 0;
|
|
|
+ this.data.list.forEach(v => v.complete ? count += 1 : '')
|
|
|
+ this.setData({
|
|
|
+ disabled: !(count == this.data.list.length)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onShareAppMessage() {}
|
|
|
+})
|