import Api from '~/service/Api';
import Utils from "~/utils"
import commonFunctions from '~/mixin/commonFunctions.js';
import moment from 'moment'
export default {
	mixins: [commonFunctions],
	methods: {
		//重置
		handleReset() {
			this.model.operatorId = '';
			this.model.inidatfro = '';
			this.model.inidattil = '';
		},

		//查询列表
		async handleSearch() {
			let inidatfro = this.model.inidatfro;
			if (!inidatfro) {
				this.$notify.error({
					title: '错误',
					message: '查询开始日期必输!'
				});
				return;
			}
			let inidattil = this.model.inidattil;
			if (!inidattil) {
				this.$notify.error({
					title: '错误',
					message: '查询结束日期必输!'
				});
				return;
			}
			let params = {
        ownref: this.model.ownref,
        cla: this.model.cla,
        status: this.model.status,
        usr: this.model.usr,
				startDate: inidatfro,
        endDate: inidattil,
        pageNo: this.pagination.pageIndex,
				pageSize: this.pagination.pageSize,
			};
			//查询接口
			const loading = this.loading();
			const res = await Api.post('/public/taskdist/config/changelog/loglist', params);
			if (res.respCode === SUCCESS) {
				this.stmData.data = res.data.records;
				this.pagination.total = Number(res.data.total);
			}
			loading.close();
    },
    
    async queryUsrByBch(){
      let params ={
        branch:JSON.parse(window.sessionStorage.currentOrg).departmentNumber
      }
     let rtnmsg = await Api.post('/public/taskdist/user/getUsrByBch',params);
      if(rtnmsg.respCode === SUCCESS){
        this.usrs = rtnmsg.data
      }
    },

		currentChange(num) {
			this.currentPage = num;
			this.getTableData();
		},

	
		beforeClose(done) {
			this.dialogTableVisible = false;
			this.currentPage = 1;
			done();
		},

		
		
		// pageSize改变
		handleSizeChange(val) {
			this.pagination.pageIndex = 1;
			this.pagination.pageSize = val;
			this.handleSearch();
		},
		// 页码改变
		handleCurrentChange(val) {
			this.pagination.pageIndex = val;
			this.handleSearch();
    },
     //初始化码表
async getdbCode(codeType, uil, codeNam) {
  let params = {
    codeType: codeType,
    uil: uil ? uil : 'EN'
  }
  let rtnmsg = await Api.post("/manager/dic/listDicInfo", params)
  if (rtnmsg.respCode === SUCCESS) {
    let curList = rtnmsg.data.map(item => ({
      value: item.codeValue,
      label: item.codeName
    }));
    this.model.dbCodes[codeNam] = curList
  }
}, //表格码表格式化
getCodelabel(value,codenam) {
      const codeobj = this.model.dbCodes[codenam].find(obj => obj.value === value)
      return codeobj ? codeobj.label : value;
},
		
	},
};