|
|
@@ -0,0 +1,161 @@
|
|
|
+const _Http = getApp().globalData.http,
|
|
|
+ file = require("../../../../utils/matchingFeilType");
|
|
|
+let queue = [],
|
|
|
+ downCounter = null;
|
|
|
+Component({
|
|
|
+ data: {
|
|
|
+ sa_projectid: 0,
|
|
|
+ "content": {
|
|
|
+ nocache: true,
|
|
|
+ "pageNumber": 1,
|
|
|
+ pageTotal: 1,
|
|
|
+ total: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ lifetimes: {
|
|
|
+ detached: function () {
|
|
|
+ if (downCounter) {
|
|
|
+ clearTimeout(downCounter);
|
|
|
+ this.changeItem(queue)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /* 获取产品列表 */
|
|
|
+ getList(id, init) {
|
|
|
+ let content = this.data.content;
|
|
|
+ content.sa_projectid = id;
|
|
|
+ if (init) content.pageNumber = 1
|
|
|
+ _Http.basic({
|
|
|
+ "id": "20221021145702",
|
|
|
+ content
|
|
|
+ }).then(res => {
|
|
|
+ console.log("项目清单列表", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ res.data = res.data.map(value => {
|
|
|
+ if (value.attinfos.length == 0) return value;
|
|
|
+ value.attinfos = file.fileList(value.attinfos)
|
|
|
+ let image = value.attinfos.find(v => v.fileType == "image");
|
|
|
+ value.cover = image ? image.cover : "";
|
|
|
+ value.className = value.itemclass.length == 0 ? "暂无类目" : value.itemclass.map(v => v.itemclassname);
|
|
|
+ value.brandName = value.brand.length == 0 ? "暂无品牌" : value.brand.map(v => v.brandname);
|
|
|
+ value.discountrate = value.discountrate * 100;
|
|
|
+ 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_projectid: id
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 去选择产品 */
|
|
|
+ addProduct() {
|
|
|
+ console.log("添加产品")
|
|
|
+ let page = getCurrentPages().find(v => v.__route__ == 'packageA/project/detail'),
|
|
|
+ {
|
|
|
+ sa_projectid
|
|
|
+ } = page.data.detail;
|
|
|
+ if (page) wx.navigateTo({
|
|
|
+ url: '/packageA/select/product/select?params=' + JSON.stringify({
|
|
|
+ "id": 20221021171802,
|
|
|
+ "version": 1,
|
|
|
+ "content": {
|
|
|
+ nocache: true,
|
|
|
+ pageNumber: 1,
|
|
|
+ pageTotal: 1,
|
|
|
+ total: null,
|
|
|
+ sa_projectid,
|
|
|
+ where: {
|
|
|
+ condition: ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 处理选择产品 */
|
|
|
+ handleSelectProduct(items) {
|
|
|
+ let that = this;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '是否确认添加产品?',
|
|
|
+ complete: ({
|
|
|
+ confirm
|
|
|
+ }) => {
|
|
|
+ if (confirm) _Http.basic({
|
|
|
+ "id": 20221021145502,
|
|
|
+ "version": 1,
|
|
|
+ "content": {
|
|
|
+ "sa_projectid": that.data.sa_projectid,
|
|
|
+ items
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("报价单添加产品", res);
|
|
|
+ wx.showToast({
|
|
|
+ title: res.msg != '成功' ? res.msg : '添加成功!',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ if (res.msg == '成功') setTimeout(() => {
|
|
|
+ that.getList(that.data.sa_projectid, true)
|
|
|
+ wx.navigateBack()
|
|
|
+ }, 300)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ /* 删除产品 */
|
|
|
+ deleteItems({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20221021145602,
|
|
|
+ "content": {
|
|
|
+ "deletereason": "",
|
|
|
+ "sa_project_itemsids": detail
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("批量删除产品", res);
|
|
|
+ wx.showToast({
|
|
|
+ title: res.msg == '成功' ? '删除成功!' : res.msg,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ if (res.msg == '成功') this.setData({
|
|
|
+ list: this.data.list.filter(v => detail.indexOf(v.sa_project_itemsid) == -1)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 生成修改队列 */
|
|
|
+ changeQueue({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ let i = queue.findIndex(v => v.sa_project_itemsid == detail.sa_project_itemsid);
|
|
|
+ if (i == -1) {
|
|
|
+ queue.push(detail)
|
|
|
+ } else {
|
|
|
+ queue[i] = detail;
|
|
|
+ };
|
|
|
+ clearTimeout(downCounter)
|
|
|
+ downCounter = setTimeout(() => {
|
|
|
+ this.changeItem(queue)
|
|
|
+ }, 2000);
|
|
|
+ },
|
|
|
+ changeItem(items) {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20221021145502,
|
|
|
+ "content": {
|
|
|
+ "sa_projectid": this.data.sa_projectid,
|
|
|
+ items
|
|
|
+ }
|
|
|
+ }, false).then(res => {
|
|
|
+ console.log("批量修改产品清单", res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|