<template>
    <div class="g-main">
        <div>

            <div class="m-table">
                <h2>系统高级配置</h2>
                <div style="width: 100%; display: flex; align-items: center;">
                    <div class=""
                        style="width: 100%; display: flex; flex-direction: column;margin-left: 50px;align-items: center;justify-content: center ">
                        <div style="width: 100%; display: flex; flex-direction: column; justify-content: center">
                            <h3>12345政务热线</h3>
                            <div class="m-table"
                                style=" width: 50%; display: flex; flex-direction:column;align-items: center;justify-content: space-between;">
                                <div v-for="(item, index) in sysAdvancedList "
                                    style=" border-bottom: 1px dotted #000;width: 100%; display: flex; flex-direction: row;align-items: center;justify-content: space-between;">
                                    <div style="display: flex; flex-direction: column;">
                                        <h4 v-if="item.advancedName == '联系当事人时限'">设置“联系当事人时限”默认值:</h4>
                                        <h4 v-if="item.advancedName == '办结时限'">设置“(部门)办结时限”默认值:</h4>
                                        <h4 v-if="item.advancedName == '短信通知'">派件是否默认开启短信通知部门负责人:</h4>
                                        <h4 v-if="item.advancedName == '联系当事人时限'">“联系当事人时限”设置为“派件时间”之后的
                                            <el-input-number v-model="item.timeInterval" @change="handleChange(item)"
                                                style="width: 150px;" :min="1" label="描述文字"></el-input-number>小时
                                        </h4>
                                        <h4 v-if="item.advancedName == '办结时限'">(部门)办结时限”设置为“(上级)办结时限”的前
                                            <el-input-number v-model="item.timeInterval" @change="handleChange(item)"
                                                style="width: 150px;" :min="1" label="描述文字"></el-input-number>小时
                                        </h4>

                                    </div>
                                    <div>
                                        <el-switch v-model="item.openFlag" active-color="#13ce66"
                                            inactive-color="#eaecf0" :active-value=1 :inactive-value=0
                                            @change="handleSwitch(item)">
                                        </el-switch>
                                    </div>
                                </div>
                                <!-- <div
                                style=" border-bottom: 1px dotted #000;width: 100%; display: flex; flex-direction: row;align-items: center;justify-content: space-between;">
                                <div style="display: flex; flex-direction: column;">
                                    <h3>设置“(部门)办结时限”默认值</h3>
                                    <h3>“(部门)办结时限”设置为“（上级）办结时限”的前 <el-input-number v-model="num" @change="handleChange"
                                        style="width: 150px;"        :min="1" :max="48" label="描述文字"></el-input-number>的小时</h3>
                                </div>
                                <div>
                                    <el-switch v-model="HotlineShow" active-color="#13ce66" inactive-color="#eaecf0">
                                    </el-switch>
                                </div>
                            </div>
                            <div
                                style="width: 100%; display: flex; flex-direction: row;align-items: center;justify-content: space-between;">
                                <div style="display: flex; flex-direction: column;">
                                    <h3>派件是否默认开启短信通知部门负责人:</h3>
                                </div>
                                <div>
                                    <el-switch v-model="HotlineShow" active-color="#13ce66" inactive-color="#eaecf0">
                                    </el-switch>
                                </div>
                            </div> -->
                            </div>
                        </div>

                        <!-- 
                
                        <h3>居民上报事件</h3>
                        <div class="m-table"
                            style=" border-bottom: 1px dotted #000;width: 100%; display: flex; flex-direction: row;align-items: center;justify-content: space-between;">
                                <div
                                style="width: 100%; display: flex; flex-direction: row;align-items: center;justify-content: space-between;">
                                <div style="display: flex; flex-direction: column;">
                                    <h3>开启自动派单:</h3>
                                    <h3>开启自动派单功能须先设置“事件类型”和“处理部门”的对应关系</h3>
                                </div>
                                <div>
                                    <el-switch v-model="HotlineShow" active-color="#13ce66" inactive-color="#eaecf0">
                                    </el-switch>
                                </div>
                            </div>
                        </div> -->
                        <!-- <h3>文明币有效期设置</h3>
                        <div class="m-table"
                            style=" border-bottom: 1px dotted #000;width: 100%; display: flex; flex-direction: row;">
                            <div style="display: flex; flex-direction: column;">
                                <h3>文明币有效期设置：</h3>
                            </div>
                            <div style="margin-left: 20px;margin-top: 12px; display: flex; flex-direction: column;">
                                <template>
                                    <el-radio v-model="radio" label="1">永久有效</el-radio>
                                    <el-radio v-model="radio" label="2" style="margin-top: 10px;">
                                        <el-input-number v-model="num" @change="handleChange" :min="1"
                                            style="width: 150px;" :max="10" label="描述文字"></el-input-number>（个月）
                                    </el-radio>
                                </template>
                            </div>
                        </div> -->
                    </div>
                </div>
            </div>
        </div>

    </div>
</template>
<script>
import { requestPost } from '@/js/dai/request';
import nextTick from 'dai-js/tools/nextTick';
import { mapGetters } from 'vuex';
// import addForm from './residentCategoryComponents/addForm.vue';
import axios from 'axios';
export default {
	data() {
		return {
            radio:"",
			num:"",
            HotlineShow:1,
			customerId:"",
			sysAdvancedList:[]
		};
	},
	components: {  },
	created() {},
	computed: {
		maxTableHeight() {
			return this.$store.state.inIframe ? this.clientHeight - 410 + this.iframeHeigh : this.clientHeight - 410;
		},
		...mapGetters(['clientHeight', 'iframeHeight'])
	},
	watch: {},
	mounted() {
		this.user = this.$store.state.user;
		this.customerId=this.$store.state.customerId
		this.agencyId = this.user.agencyId;
		this.sysAdvancedPage();
	},
	methods: {
        handleSwitch(row){
            console.log(row,this.num,"sdgmlsdlgjk");
  
            const url = '/sys/sysAdvanced/update';
			const param = {
				id: row.id,
                openFlag:row.openFlag,
			};
            requestPost(url, param).then(res=>{
             if (res.code === 0) {
                 console.log("sgl.msl;kgm");

                 this.sysAdvancedPage()
             }
         });
        },
        handleChange(row){
            console.log(row,this.num,"sdgmlsdlgjk");
            const url = '/sys/sysAdvanced/update';
			const param = {
				id: row.id,
                timeInterval:row.timeInterval,
                // openFlag:this.openFlag,
                remark:row.remark.slice(0, 7)+row.timeInterval+ row.remark.slice(-2) 
			};
            console.log(param,"sdlkjggsdklf");
         requestPost(url, param).then(res=>{
             if (res.code === 0) {
                 console.log("sgl.msl;kgm");

                 this.sysAdvancedPage()
             }
         });
			
        },
        //update/id  
        // json格式的id
		async sysAdvancedPage(row) {
            console.log("dfgkljdlk;fg");
            
			const url = '/sys/sysAdvanced/page';
			const param = {
				customerId: this.customerId,
			};
			const { data, code, msg } = await requestPost(url, param);
			if (code === 0) {
				this.sysAdvancedList=data.list
            
			} else {
				this.$message.error(msg);
			}
		},

	}
};
</script>
<style lang="scss" scoped>
@import '@/assets/scss/modules/management/list-main.scss';
.m-search {
	.u-item-width-normal {
		width: 200px;
	}
}
</style>
