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 } ], buttonSaveList: [{ code: 'add', title: mixins.$t('roleAdd'), width: '120rpx' }], contentSaveList: [], // 查询条件 searchContent: [{ code: 'flgValid', key:'valueList' ,title: mixins.$t('allValidInvalid'), searchType: Constants.searchType.switch, list: [ { code: 1, title: mixins.$t('valid'), value: true,checked:true}, { code: 2, title: mixins.$t('invalid'), value: false}] }], // 路由 routeObjName: 'role', tableData: [], }, /** * @desc : 启用停用 * @date : 2024/2/1 15:49 * @author : 于继渤 */ deactivateEnable(e) { this.handleMoreDataIsValid(this.data.service, e.detail.item, 'roleId') }, /** * @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 : 于继渤 */ handleSearchData(tableData) { tableData.forEach(res => { res.displayStatus = res.flgValid ? null : mixins.$t('disable') res.backgroundColor = res.flgValid ? '' : 'red' }) this.setData({ tableData: tableData }) }, /** * @desc : 设置参数 * @date : 2024/2/1 15:49 * @author : 于继渤 */ setSearchParams(params) { params.flgValidList = params.flgValidList ? params.flgValidList : [true] 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.setData({ pageInfo: { currentPage: 1, pageSize: 5 } }) this.searchData() } } })