123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- const _Http = getApp().globalData.http,
- file = require("../../../../utils/FormatTheAttachment");
- let queue = [],
- downCounter = null;
- Component({
- properties: {
- disabled: {
- type: Boolean
- }, //禁用
- },
- data: {
- sa_aftersalesmagid: 0,
- "content": {
- nocache: true,
- "pageNumber": 1,
- pageTotal: 1,
- total: null
- }
- },
- lifetimes: {
- detached: function () {
- if (downCounter) {
- clearTimeout(downCounter);
- this.changeItem(queue)
- }
- },
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- }
- },
- methods: {
- /* 获取产品列表 */
- getList(id, init) {
- let content = this.data.content;
- content.sa_aftersalesmagid = id;
- if (init) content.pageNumber = 1;
- _Http.basic({
- "id": "20230105111103",
- content
- }).then(res => {
- console.log("订货清单列表", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- res.data = res.data.map(value => {
- if (value.attinfos.length != 0) {
- value.attinfos = file.fileList(value.attinfos)
- let image = value.attinfos.find(v => v.fileType == "image");
- value.cover = image ? image.cover : "";
- }
- return value;
- })
- this.setData({
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- "content.pageNumber": res.pageNumber + 1,
- "content.pageSize": res.pageSize,
- "content.pageTotal": res.pageTotal,
- "content.total": res.total,
- sa_aftersalesmagid: id,
- })
- })
- },
- /* 修改 */
- changeProduct({
- detail
- }) {
- let obj = detail,
- index = this.data.list.findIndex(v => v.itemid == detail.itemid),
- data = this.data.list[index],
- page = getCurrentPages()[getCurrentPages().length - 1]
- if (data.qty == obj.qty && data.reason == obj.reason && data.price == obj.price) return;
- _Http.basic({
- "id": 20230105111003,
- "content": {
- "sa_aftersalesmagid": page.data.sa_aftersalesmagid,
- "iteminfos": [detail]
- }
- }).then(res => {
- console.log("产品修改", res)
- if (res.code != '1') {
- wx.showToast({
- title: res.msg,
- icon: "none"
- });
- obj = data;
- };
- data = {
- ...data,
- ...obj
- };
- data.amount = res.data[0].amount
- console.log(data);
- this.setData({
- [`list[${index}]`]: data
- })
- })
- },
- /* 删除 */
- deleteItem({
- detail
- }) {
- let that = this;
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确认删除') + `“${detail.itemname}”?`,
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20230105111203,
- "content": {
- sa_aftersalesmag_itemsids: [detail.sa_aftersalesmag_itemsid],
- }
- }).then(s => {
- if (s.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- that.setData({
- list: that.data.list.filter(v => v.sa_orderitemsid != detail.sa_orderitemsid)
- });
- })
- }
- })
- },
- /* 去添加产品 */
- addProduct() {
- let detail = getCurrentPages().find(v => v.__route__ == 'packageA/toolBill/detail').data.detail;
- let id = ''
- wx.navigateTo({
- url: `/packageA/toolBill/modules/selectProduct/index?params=${JSON.stringify({
- "id":20230105110903,
- "content": {
- nocache:true,
- "sa_orderid": detail.sa_orderid, //订单ID
- "sa_aftersalesmagid": detail.sa_aftersalesmagid, //订单ID
- "pageNumber": 1,
- "pageTotal": 1,
- "total": 0,
- "pageSize": 20,
- "where": {
- "condition": ""
- }
- }
- })}`
- });
- getApp().globalData.handleSelect = this.handleSelect.bind(this);
- },
- /* 处理新增产品 */
- handleSelect(detail) {
- let that = this;
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.joint([{
- t: 1,
- v: '是否确认添加',
- }, {
- v: detail.result.length,
- f: "“",
- r: "”"
- }, {
- t: 1,
- v: '件商品',
- r: "?"
- }]),
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20230105111003,
- "content": {
- sa_aftersalesmagid: that.data.sa_aftersalesmagid,
- "iteminfos": detail.list.map(v => {
- return {
- "sa_aftersalesmag_itemsid": 0,
- "sa_orderitemsid": v.sa_orderitemsid,
- "itemid": v.itemid,
- "reason": '',
- "qty": v.qty,
- "price": v.price
- }
- })
- }
- }).then(s => {
- console.log('新增产品', s)
- wx.showToast({
- title: s.code == '1' ? getApp().globalData.Language.getMapText('添加成功') : s.msg,
- icon: "none"
- });
- if (s.code == '1') setTimeout(() => {
- that.getList(that.data.sa_aftersalesmagid, true);
- wx.navigateBack();
- }, 300)
- })
- }
- });
- },
- }
- })
|