| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- const _Http = getApp().globalData.http;
- import currency from "../../utils/currency";
- let content = null;
- Page({
- data: {
- isInsert: false,
- CustomBar: getApp().globalData.CustomBar,
- privacyFieldC: [],
- },
- onLoad(options) {
- if (wx.getStorageSync('auth').worderform.options.some(v => v == 'insert')) this.setData({
- isInsert: true
- })
- content = {
- nocache: true,
- "isExport": 0,
- "pageNumber": 1,
- "pageTotal": 1,
- "where": {
- "condition": "",
- type: '标准订单',
- tablefilter: {}
- }
- };
- this.getList()
- try {
- let privacyFieldC = wx.getStorageSync('auth').worderform.forms.list.formcols.map(v => v.title);
- this.setData({
- privacyFieldC
- })
- console.log("privacyFieldC", privacyFieldC)
- } catch (error) {
- console.error(error)
- }
- },
- /* 获取产品 */
- getList(init = false) {
- if (init.detail != undefined) init = init.detail;
- if (init) content.pageNumber = 1;
- if (content.pageNumber > content.pageTotal) return;
- this.setListHeight();
- _Http.basic({
- "id": 20221224180302,
- content
- }).then(res => {
- console.log("订单列表", res)
- this.selectComponent('#ListBox').RefreshToComplete();
- /* 格式化价格 */
- if (res.data.length != 0) res.data = res.data.map(v => {
- v.defaultamount = currency(v.defaultamount, {
- symbol: "¥",
- precision: 2
- }).format();
- return v
- })
- content.pageNumber = res.pageNumber + 1
- content.pageTotal = res.pageTotal
- this.setData({
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- total: res.total,
- amount: currency(res.tips.amount, {
- symbol: "¥",
- precision: 2
- }).format()
- })
- })
- },
- /* 更新列表 */
- updateList() {
- let params = JSON.parse(JSON.stringify(content));
- params.pageSize = (params.pageNumber - 1) * params.pageSize;
- params.pageNumber = 1;
- _Http.basic({
- "id": 20221224180302,
- content: params
- }).then(res => {
- console.log("订单列表", res)
- if (res.msg != '成功') return;
- /* 格式化价格 */
- if (res.data.length != 0) res.data = res.data.map(v => {
- v.defaultamount = currency(v.defaultamount, {
- symbol: "¥",
- precision: 2
- }).format();
- return v
- })
- this.setData({
- list: res.data,
- total: res.total,
- amount: currency(res.tips.amount, {
- symbol: "¥",
- precision: 2
- }).format()
- })
- })
- },
- /* 切换tabs */
- tabsChange(e) {
- let status = "";
- switch (e.detail.title) {
- case '全部':
- status = "";
- break;
- case '待确认':
- status = "交期待确认";
- break;
- default:
- status = e.detail.title
- break;
- }
- content.where.tablefilter.status = status;
- content.where.status = status;
- this.getList(true);
- },
- /* 搜索 */
- onSearch({
- detail
- }) {
- content.where.condition = detail;
- this.getList(true)
- },
- /* 设置页面高度 */
- setListHeight() {
- this.selectComponent("#ListBox").setHeight(".header", this);
- },
- showModal(e) {
- this.setData({
- modalName: e.currentTarget.dataset.target
- })
- },
- hideModal(e) {
- this.setData({
- modalName: null
- })
- },
- createOrder() {
- _Http.basic({
- "classname": "common.usercenter.usercenter",
- "method": "queryUserMsg",
- "content": {},
- }).then(res => {
- console.log("获取经销商数据", res)
- if (res.code != 1) return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- let sys_enterpriseid = res.data.hr.sys_enterpriseid;
- let queryList = [{
- "id": 20221008134803,
- "version": 1,
- "content": {
- "pageNumber": 1,
- "pageTotal": 1,
- "pageSize": 9999,
- "where": {
- "condition": "",
- "isused": 1,
- "isnotspecialfund": 0,
- },
- }
- }, {
- "id": "20221013160602",
- "content": {
- sys_enterpriseid,
- "where": {
- "tablefilter": {}
- }
- }
- }, {
- "id": "20221009155803",
- "content": {
- sys_enterpriseid,
- "pageSize": 1000,
- "where": {
- "workaddress": 1
- }
- }
- }],
- content = {
- sa_orderid: 0,
- rec_contactsid: 0,
- pay_enterpriseid: 0,
- sa_contractid: 0,
- sa_projectid: 0,
- sa_accountclassid: 0,
- "sa_brandid": 0, //品牌ID
- "type": '标准订单', //订单类型
- "tradefield": '默认', //必选
- sys_enterpriseid
- };
- Promise.all(queryList.map(v => _Http.basic(v))).then(res1 => {
- res1.forEach((v, index) => {
- if (queryList[index].id == 20221013160602) {
- if (v.code == 1) {
- try {
- let item = v.data.find(s => s.isdefault);
- if (!item && v.data.length) item = v.data[0];
- content.sys_enterprise_financeid = item.sys_enterprise_financeid;
- content.invoicename = item.enterprisename;
- content.invoicetaxno = item.taxno;
- content.invoiceaddress = item.address;
- content.finance = item;
- } catch (error) {
- console.log("获取开票方式错误", error)
- console.log("开票方式数据", v.data)
- }
- }
- } else if (queryList[index].id == 20221008134803) {
- if (v.code == 1) {
- try {
- let item = v.data.find(v => v.accountname == '现金账户');
- if (!item && v.data.length) item = v.data[0];
- content.sa_accountclassid = item.sa_accountclassid;
- } catch (error) {
- console.log("账户错误", error)
- console.log("账户数据", v.data)
- }
- }
- } else {
- // 收货地址
- if (v.code == 1) {
- let list = v.data.filter(v => v.type == '收货')
- let item = list.find(s => s.isdefault);
- if (!item && list.length) item = list[0];
- if (!item) return;
- content.contact = item.name;
- content.name = item.name;
- content.phonenumber = item.phonenumber;
- content.province = item.province;
- content.city = item.city;
- content.county = item.county;
- content.address = item.address;
- content.rec_contactsid = item.contactsid;
- content.contacts = item;
- }
- }
- })
- if (!content.invoicename) return wx.showModal({
- title: "提示",
- content: "开票信息不完整:请联系总部公司补充开票信息",
- showCancel: false
- })
- if (!content.contact) return wx.showModal({
- title: "提示",
- content: "收货信息不完整:请联系总部公司补充收货信息",
- showCancel: false
- })
- this.handleAdd(content)
- })
- })
- },
- handleAdd(content) {
- wx.showModal({
- title: '提示',
- content: `是否确定创建订单`,
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 20221108111402,
- content
- }).then(res => {
- console.log(`创建标准订单`, res);
- wx.showToast({
- title: res.msg != '成功' ? res.msg : '创建成功',
- icon: "none",
- mask: true
- });
- if (res.msg == '成功') setTimeout(() => {
- wx.navigateTo({
- url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
- });
- }, 500)
- })
- }
- })
- }
- })
|