123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- const _Http = getApp().globalData.http;
- import currency from "../../utils/currency";
- Page({
- data: {
- loading: true,
- active: "新建",
- "content": {
- nocache: true,
- "pageNumber": 1,
- "pageTotal": 1,
- "pageSize": 20,
- "isManage": 0, //默认是1,表示管理端,0表示非管理端,根据用户类型自动区分业务员还是经销商
- "isExport": 0,
- total: 0,
- "where": {
- "condition": "",
- },
- sort: []
- },
- filter: [{
- label: "品牌",
- index: null,
- showName: "brandname", //显示字段
- valueKey: "brandname", //返回Key
- selectKey: "brandname", //传参 代表选着字段 不传参返回整个选择对象
- value: "", //选中值
- list: []
- }, {
- label: "领域",
- index: null,
- showName: "tradefield", //显示字段
- valueKey: "tradefield", //返回Key
- selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
- value: "", //选中值
- list: []
- }],
- createShow: false,
- types: [{
- name: "按借用合同借用"
- }, {
- name: "单个借用"
- }]
- },
- onLoad(options) {
- this.getList(true)
- this.setData({
- userrole: wx.getStorageSync('userrole')
- })
- },
- /* 处理筛选 */
- handleFilter({
- detail
- }) {
- console.log(detail)
- },
- getList(init = false) {
- if (init.detail != undefined) init = init.detail;
- let content = this.data.content;
- if (init) content.pageNumber = 1;
- if (content.pageNumber > content.pageTotal) return;
- content.where.status = this.data.active;
- _Http.basic({
- "id": 20230114105002,
- "version": 1,
- content
- }).then(res => {
- console.log("工具借用列表", res)
- this.selectComponent('#ListBox').RefreshToComplete();
- res.data = res.data.map(v => {
- v.amount = currency(v.amount, {
- symbol: "¥",
- precision: 2
- }).format()
- return v
- })
- this.setData({
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- "content.pageNumber": res.pageNumber + 1,
- "content.pageTotal": res.pageTotal,
- "content.sort": res.sort,
- "content.total": res.total,
- loading: false
- })
- })
- },
- /* 去新增 */
- openAction() {
- this.setData({
- createShow: true
- })
- },
- createBor({
- detail
- }) {
- this.onCancel();
- if (detail.name == '按借用合同借用') {
- wx.navigateTo({
- url: `/select/contract/index?params=${JSON.stringify({
- "id": 20230114092502,
- "content": {
- nocache: true,
- "pageNumber": 1,
- "pageTotal": 1,
- "total": null,
- "pageSize": 20,
- "where": {
- "condition": ""
- }
- }
- })}&radio=false`
- })
- getApp().globalData.handleSelect = this.handleCreated.bind(this);
- } else {
- if (this.data.userrole == '业务员') {
- wx.navigateTo({
- url: `/select/agent/index?params=${JSON.stringify({
- "id": 20220920083901,
- "content": {
- nocache:true,
- "where": {
- "condition": "",
- "type":9,
- }
- }
- })}&radio=true`,
- })
- getApp().globalData.handleSelect = this.handleSingle.bind(this);
- } else {
- _Http.basic({
- "id": 20230116092702,
- "content": {
- "sa_orderid": 0
- }
- }).then(res => {
- console.log("按个", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- wx.navigateTo({
- url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
- })
- })
- }
- }
- },
- handleSingle({
- item
- }) {
- wx.showModal({
- title: '提示',
- content: `是否确定选择"${item.enterprisename}"创建工具借用单?`,
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20230116092702,
- "content": {
- "sa_orderid": 0,
- sys_enterpriseid: item.sys_enterpriseid
- }
- }).then(res => {
- console.log("按个", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- wx.redirectTo({
- url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
- })
- })
- }
- })
- },
- handleCreated(e) {
- wx.showModal({
- title: '提示',
- content: `是否确认选择“${e.item.title}”创建借用单`,
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 20230116092702,
- "content": {
- "sa_contractid": e.id[0],
- "sa_orderid": 0
- }
- }).then(res => {
- console.log("按套", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- _Http.basic({
- "id": 20230116142602,
- "content": {
- "sa_orderid": res.data.sa_orderid,
- "sys_enterpriseid": res.data.sys_enterpriseid,
- "sa_contractid": e.id[0]
- }
- }, false).then(s => {
- console.log("复制合同商品", s)
- wx.redirectTo({
- url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
- })
- })
- })
- }
- })
- },
- onCancel() {
- this.setData({
- createShow: false
- })
- },
- /* 搜索 */
- onSearch({
- detail
- }) {
- this.setData({
- "content.where.condition": detail
- });
- this.getList(true)
- },
- /* 切换tabs */
- tabsChange(e) {
- let status = "";
- switch (e.detail.title) {
- case '全部':
- status = "";
- break;
- case '待确认':
- status = "交期待确认";
- break;
- default:
- status = e.detail.title
- break;
- }
- this.setData({
- active: status
- });
- this.getList(true);
- },
- onReady() {
- this.setListHeight()
- },
- /* 设置页面高度 */
- setListHeight() {
- this.selectComponent("#ListBox").setHeight(".total", this);
- },
- })
|