123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import {
- ApiModel
- } from "../../utils/api"
- const _Http = new ApiModel();
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- /* 标题 */
- title: {
- type: String,
- },
- /* 选中列表 */
- saleprodclass: {
- type: Array,
- value: []
- },
- /* 回调 */
- saleprodChange: {
- type: Function
- },
- /* 分类列表 */
- dataList: {
- type: Array,
- value: []
- },
- /* 是否请求 */
- isRequest: {
- type: Boolean,
- value: true
- }
- },
- lifetimes: {
- attached: function () {
- //查询类目列表
- if (this.data.isRequest) _Http.basic({
- "accesstoken": wx.getStorageSync('userData').token,
- "classname": "enterprise.system.prodclass",
- "method": "query_typeselectList",
- "content": {}
- }).then(res => {
- if (res.msg != '成功') return;
- let dataList = [];
- for (let i = 0; i < res.data.length; i++) {
- dataList.push({
- value: res.data[i],
- index: i,
- checked: false
- })
- }
- //遍历选中数据
- const arr = this.data.saleprodclass;
- for (let i = 0; i < arr.length; i++) {
- for (let k = 0; k < dataList.length; k++) {
- if (arr[i] == dataList[k].value) {
- dataList[k].checked = true;
- break;
- }
- }
- }
- this.setData({
- dataList
- })
- })
- },
- },
- /**
- * 组件的初始数据
- */
- data: {
- pitchOnList: [], //选中列表
- },
- /**
- * 组件的方法列表
- */
- methods: {
- /* 确定 */
- confirm() {
- this.triggerEvent("saleprodChange", this.data.pitchOnList)
- },
- /* 多选框返回数值 */
- checkedChange(e) {
- this.setData({
- pitchOnList: e.detail.value
- });
- },
- /* 添加背景色 */
- pitchOn(e) {
- let dataList = this.data.dataList;
- dataList[e.currentTarget.dataset.index].checked = !dataList[e.currentTarget.dataset.index].checked
- this.setData({
- dataList
- })
- }
- }
- })
|