|
@@ -0,0 +1,133 @@
|
|
|
|
|
+const _Http = getApp().globalData.http,
|
|
|
|
|
+ getHeight = require("../../../utils/getRheRemainingHeight");
|
|
|
|
|
+Page({
|
|
|
|
|
+ data: {
|
|
|
|
|
+ item: {},
|
|
|
|
|
+
|
|
|
|
|
+ result: [],
|
|
|
|
|
+ radio: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ onLoad(options) {
|
|
|
|
|
+ /* 从表单组件进入进入 */
|
|
|
|
|
+ if (options.item) {
|
|
|
|
|
+ let item = JSON.parse(options.item);
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ item,
|
|
|
|
|
+ result: item.value.length ? item.value[1] : [],
|
|
|
|
|
+ params: item.params
|
|
|
|
|
+ })
|
|
|
|
|
+ };
|
|
|
|
|
+ if (options.params) this.setData({
|
|
|
|
|
+ params: JSON.parse(options.params)
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ radio: options.radio ? true : false
|
|
|
|
|
+ });
|
|
|
|
|
+ this.getList()
|
|
|
|
|
+ },
|
|
|
|
|
+ submit() {
|
|
|
|
|
+ let pages = getCurrentPages(),
|
|
|
|
|
+ item = this.data.item,
|
|
|
|
|
+ result = this.data.result,
|
|
|
|
|
+ list = result.map(v => this.data.list.find(value => value.sys_enterpriseid == v));
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ let page = pages[pages.length - 2].selectComponent(item.model || "#Form");
|
|
|
|
|
+ item.value = this.data.radio ? [list[0].enterprisename, result] : [list.map(v => v.enterprisename), result];
|
|
|
|
|
+ page.handleRoute(item, list);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ pages[pages.length - 2].handleSelectProject(this.data.result, list)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '操作失败',
|
|
|
|
|
+ icon: "none"
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ getList(init = false) {
|
|
|
|
|
+ //init 用于初始化分页
|
|
|
|
|
+ if (init.detail != undefined) init = init.detail;
|
|
|
|
|
+ let params = this.data.params;
|
|
|
|
|
+ if (init) params.content.pageNumber = 1;
|
|
|
|
|
+ if (params.content.pageNumber > params.content.pageTotal) return;
|
|
|
|
|
+ _Http.basic(params).then(res => {
|
|
|
|
|
+ console.log("选择经销商列表", res)
|
|
|
|
|
+ this.selectComponent('#ListBox').RefreshToComplete();
|
|
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
|
|
+ title: res.data,
|
|
|
|
|
+ icon: "none"
|
|
|
|
|
+ })
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ 'params.content.pageNumber': res.pageNumber + 1,
|
|
|
|
|
+ 'params.content.pageTotal': res.pageTotal,
|
|
|
|
|
+ 'params.content.total': res.total,
|
|
|
|
|
+ list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
|
|
|
|
|
+ })
|
|
|
|
|
+ this.getTags();
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ /* 获取列表标签 */
|
|
|
|
|
+ getTags() {
|
|
|
|
|
+ let list = this.data.list,
|
|
|
|
|
+ ownerids = list.map(v => v.sys_enterpriseid);
|
|
|
|
|
+ _Http.basic({
|
|
|
|
|
+ "id": 20221018102001,
|
|
|
|
|
+ "content": {
|
|
|
|
|
+ "ownertable": "sys_enterprise",
|
|
|
|
|
+ ownerids
|
|
|
|
|
+ }
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ console.log("经销商标签", res)
|
|
|
|
|
+ for (let key in res.data) {
|
|
|
|
|
+ let index = list.findIndex(v => v.sys_enterpriseid == key);
|
|
|
|
|
+ if (index != -1) list[index].tags = res.data[key]
|
|
|
|
|
+ };
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ list
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ /* 选中 */
|
|
|
|
|
+ changeResult(e) {
|
|
|
|
|
+ const {
|
|
|
|
|
+ id
|
|
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
|
|
+ let result = this.data.result;
|
|
|
|
|
+ if (this.data.radio) {
|
|
|
|
|
+ result = [id];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (result.some(v => v == id)) {
|
|
|
|
|
+ result = result.filter(v => v != id);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result.push(id)
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ result
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ /* 开始搜索 */
|
|
|
|
|
+ startSearch({
|
|
|
|
|
+ detail
|
|
|
|
|
+ }) {
|
|
|
|
|
+ if (detail == this.data.content.where.condition) return;
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ 'content.where.condition': detail
|
|
|
|
|
+ });
|
|
|
|
|
+ this.getList(true);
|
|
|
|
|
+ },
|
|
|
|
|
+ /* 取消搜索 */
|
|
|
|
|
+ onClear() {
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ 'content.where.condition': ""
|
|
|
|
|
+ });
|
|
|
|
|
+ this.getList(true);
|
|
|
|
|
+ },
|
|
|
|
|
+ onReady() {
|
|
|
|
|
+ getHeight.getHeight('.total', this).then(res => this.setData({
|
|
|
|
|
+ listHeight: res
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+})
|