﻿<template>
	<el-dialog :title="!dataForm.id ? '新建' :  isDetail ? '详情':'编辑'" :close-on-click-modal="false" :visible.sync="visible" class="NCC-dialog NCC-dialog_center" lock-scroll width="600px">
		<el-row :gutter="15" class="" >
				<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" :disabled="!!isDetail" :rules="rules">
					<el-col :span="24" v-if="false" >
						<el-form-item label="主键" prop="id">
							<el-input v-model="dataForm.id" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="门店编号" prop="mdbh">
							<el-input v-model="dataForm.mdbh" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="门店名称" prop="mdmc">
							<el-input v-model="dataForm.mdmc" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="教育部" prop="jyb">
							<el-input v-model="dataForm.jyb" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="开始时间" prop="kssj1">
							<el-date-picker v-model="dataForm.kssj1" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="结束时间" prop="jssj1">
							<el-date-picker v-model="dataForm.jssj1" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="教育部老师" prop="jybls">
							<el-input v-model="dataForm.jybls" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="开始时间" prop="kssj2">
							<el-select v-model="dataForm.kssj2" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in kssj2Options" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="结束时间" prop="jssj2">
							<el-select v-model="dataForm.jssj2" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in jssj2Options" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="科技部" prop="kjb">
							<el-input v-model="dataForm.kjb" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="开始时间" prop="kssj3">
							<el-date-picker v-model="dataForm.kssj3" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="结束时间" prop="jssj3">
							<el-date-picker v-model="dataForm.jssj3" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="大项目部" prop="dxmb">
							<el-input v-model="dataForm.dxmb" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="开始时间" prop="kssj4">
							<el-date-picker v-model="dataForm.kssj4" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="结束时间" prop="jssj4">
							<el-date-picker v-model="dataForm.jssj4" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="事业部" prop="syb">
							<el-input v-model="dataForm.syb" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="事业部开始" prop="sybssksrq">
							<el-date-picker v-model="dataForm.sybssksrq" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="事业部终止" prop="sybsszzrq">
							<el-date-picker v-model="dataForm.sybsszzrq" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="老店类型" prop="mdlx">
							<el-select v-model="dataForm.mdlx" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in mdlxOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="门店状态" prop="mdzt">
							<el-select v-model="dataForm.mdzt" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in mdztOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="新店类型" prop="xdlx">
							<el-select v-model="dataForm.xdlx" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in xdlxOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="新店开始日期" prop="xdssksrq">
							<el-date-picker v-model="dataForm.xdssksrq" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="新店终止日期" prop="xdsszzrq">
							<el-date-picker v-model="dataForm.xdsszzrq" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="生命线-固定" prop="smx">
							<el-input v-model="dataForm.smx" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
				</el-form>
		</el-row>
		<span slot="footer" class="dialog-footer">
			<el-button @click="visible = false">取 消</el-button>
			<el-button type="primary" @click="dataFormSubmit()" v-if="!isDetail">确 定</el-button>
		</span>
	</el-dialog>
</template>
<script>
	import request from '@/utils/request'
	import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
	import { previewDataInterface } from '@/api/systemData/dataInterface'
	export default {
		components: {},
		props: [],
		data() {
			return {
				loading: false,
				visible: false,
				isDetail: false,
				dataForm: {
					id:'',
					id:undefined,
					mdbh:undefined,
					mdmc:undefined,
					jyb:undefined,
					kssj1:undefined,
					jssj1:undefined,
					jybls:undefined,
					kssj2:undefined,
					jssj2:undefined,
					kjb:undefined,
					kssj3:undefined,
					jssj3:undefined,
					dxmb:undefined,
					kssj4:undefined,
					jssj4:undefined,
					syb:undefined,
					sybssksrq:undefined,
					sybsszzrq:undefined,
					mdlx:undefined,
					mdzt:undefined,
					xdlx:undefined,
					xdssksrq:undefined,
					xdsszzrq:undefined,
					smx:undefined,
				},
				rules: {
				},
				kssj2Options:[{"fullName":"选项一","id":"1"},{"fullName":"选项二","id":"2"}],
				jssj2Options:[{"fullName":"选项一","id":"1"},{"fullName":"选项二","id":"2"}],
				mdlxOptions:[{"fullName":"A类","id":"A类"},{"fullName":"B类","id":"B类"}],
				mdztOptions:[{"fullName":"新店","id":"新店"},{"fullName":"老店","id":"老店"}],
				xdlxOptions:[{"fullName":"A类","id":"A类"},{"fullName":"B类","id":"B类"}],
			}
		},
		computed: {},
        watch: {},
        created() {
		},
		mounted() {
        },
		methods: {
			goBack() {
                this.$emit('refresh')
            },
			init(id, isDetail) {
				this.dataForm.id = id || 0;
                this.visible = true;
                this.isDetail = isDetail || false;
				this.$nextTick(() => {
					this.$refs['elForm'].resetFields();
					if (this.dataForm.id) {
						request({
							url: '/api/Extend/LqYcsdMdlbjhsxx/' + this.dataForm.id,
							method: 'get'
						}).then(res =>{
							this.dataForm = res.data;
						})
					}
				})
			},
			dataFormSubmit() {
				this.$refs['elForm'].validate((valid) => {
                    if (valid) {
                        if (!this.dataForm.id) {
                            request({
                                url: `/api/Extend/LqYcsdMdlbjhsxx`,
                                method: 'post',
                                data: this.dataForm,
                            }).then((res) => {
                                this.$message({
                                    message: res.msg,
                                    type: 'success',
                                    duration: 1000,
                                    onClose: () => {
                                        this.visible = false,
                                            this.$emit('refresh', true)
                                    }
                                })
                            })
                        } else {
                            request({
                                url: '/api/Extend/LqYcsdMdlbjhsxx/' + this.dataForm.id,
                                method: 'PUT',
                                data: this.dataForm
                            }).then((res) => {
                                this.$message({
                                    message: res.msg,
                                    type: 'success',
                                    duration: 1000,
                                    onClose: () => {
                                        this.visible = false
                                        this.$emit('refresh', true)
                                    }
                                })
                            })
                        }
                    }
                })
			},
		}
	}
</script>
