const Constants = require('@/utils/Constants.js'); const util = require('@/utils/util.js') const mixins = require('@/mixins/index.js') Page({ mixins: [mixins], /** * 页面的初始数据 */ data: { // 列表区(内容) contentList: [{ name: 'roleCode', title: mixins.$t('roleCode') }, { name: 'remarks', title: mixins.$t('roleRemarks') }], // 弹出按钮 buttonList: [ { name: 'selectFunctionalPermissions', title: mixins.$t('functionalPermissions'),formType:Constants.formMode.add }, { name: 'copyAdd', title: mixins.$t('copyAndAdd'),formMode: Constants.formMode.edit,formType: Constants.formMode.add, idKey: 'roleId', }, { name: 'selectSensitiveData', title: mixins.$t('sensitiveData'),formType: Constants.formMode.add } ], // 路由 routeObjName: 'role', tableData: [], }, /** * @desc : 启用停用 * @date : 2024/2/1 15:49 * @author : 于继渤 */ deactivateEnable(e) { let item = e.detail.item let method = item.flgValid ? this.data.service.disable : this.data.service.enable; return this.excute(this.data.service, method, item.roleId).then(res => { if (res.data.code == 200) { wx.showToast({ title: '操作成功', image: '/static/image/success.png', duration: 1000 }) //查询列表 this.searchData() } }); }, /** * @desc : 三点事件 * @date : 2024/2/1 15:49 * @author : 于继渤 */ toPoint(e) { this.setButtonList(e.detail.item) }, /** * @desc : 更新三点文字信息 * @date : 2024/2/1 15:49 * @author : 于继渤 */ setButtonList(item) { let buttonList = this.data.buttonList buttonList.forEach(res => { if (res.name == 'collection' && item.flgValid) { res.title = mixins.$t('disable') } else if (res.name == 'collection' && !item.flgValid) { res.title = mixins.$t('enable') } }) this.setData({ buttonList: buttonList }) }, /** * @desc : 新建跳转 * @date : 2024/2/1 15:49 * @author : 于继渤 */ toAdd() { wx.navigateTo({ url: this.data.route.add.url, events: function (e) { console.log('回调后,在这里给页面赋值') // 回调后,在这里给页面赋值 }, success: function (res) { // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取 res.eventChannel.emit('params', {}) } }) }, /** * @desc : 处理接口返回数据 * @date : 2024/2/1 15:49 * @author : 于继渤 */ handleSearchData(tableData) { tableData.forEach(res => { res.displayStatus = res.flgValid ? mixins.$t('enable') : mixins.$t('disable') res.backgroundColor = res.flgValid ? '' : 'red' }) this.setData({ tableData: tableData }) }, setSearchParams(params){ return params }, /** * @desc : 加载数据源 * @date : 2024/2/1 15:49 * @author : 于继渤 */ getData(params) { return this.excute(this.data.service, this.data.service.selectByCond, params); }, /** * @desc : 详细页面 * @date : 2024/2/1 15:49 * @author : 于继渤 */ toDetail(e) { let roleId = e.detail.item.roleId this.setData({ selectflag: true }) wx.navigateTo({ url: this.data.route.add.url, success: function (res) { // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取 res.eventChannel.emit('params', { id: roleId, formMode: Constants.formMode.edit }) } }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, onShow(){ if(this.data.refreshDataFlag){ this.searchData() } } })