var vm = null;
export const sendThis = ( _this )=> {
  vm = _this;
	let orderStatus = vm.orderStatus, deptId=vm.deptId;
	var _option = {
		height: 'auto',
		calcHeight: 32,
		selection: true,
		index: true,
		indexLabel: '序号',
		indexWidth: 60,
		menu:false,
		menuFixed: true,
		menuWidth: 200,
		addBtn:false,
		border: true,
		searchMenuSpan:6,
		searchMenuPosition: "left",
		searchGutter:0,
		searchLabelWidth:90,
		column: [{
				label: '服务商名称',
				prop: 'siteName',
				minWidth: 200,
				search: (deptId == '3' || deptId == '5') ? false : true,
				display:false,
				fixed:true,
				hide:(deptId == '3' || deptId == '5') ? true : false,
			},
			{
				label: '工单编号',
				prop: 'number',
				minWidth: 180,
				search: true,
				display:false,
				fixed:true,
			},
			{
				label: '工单状态',
				prop: 'status',
				minWidth: 100,
				search: (deptId == '3' || deptId == '5') || orderStatus == '1' || orderStatus == '2' || orderStatus == '4' || orderStatus == '5' ? false : true,
				display:false,
				type: 'select',
				dicUrl: '/blade-system/dict/dictionary?code=order_status',
				props: {
					label: 'dictValue',
					value: 'dictKey',
				},
				hide:(deptId == '3' || deptId == '5') || orderStatus == '1' || orderStatus == '2' || orderStatus == '4' || orderStatus == '5' ? true : false,
			},
			{
				label: '工单状态',
				prop: 'siteStatus',
				minWidth: 120,
				search: ((deptId == '3' || deptId == '5') && orderStatus != '1' && orderStatus != '4' && orderStatus != '5') || orderStatus == '2' ? true : false,
				display:false,
				type: 'select',
				dicUrl: '/blade-system/dict/dictionary?code=site_order_status',
				props: {
					label: 'dictValue',
					value: 'dictKey',
				},
				hide:((deptId == '3' || deptId == '5') && orderStatus != '1' && orderStatus != '4' && orderStatus != '5') || orderStatus == '2' ? false : true,
				dicFormatter:(res)=>{
					if(orderStatus == '2'){
						let data = res.data.filter(itm=> itm.dictKey == '1' || itm.dictKey == '3' || itm.dictKey == '4' || itm.dictKey == '5' || itm.dictKey == '6');
						return data;
					}else{
						return res.data;
					}
				}
			},
			{
				label: '过程反馈',
				prop: 'latestProcess',
				minWidth: 200,
				hide:orderStatus == '2' || orderStatus == '4' ? false : true
			},
			{
				label: '电站编码',
				prop: 'powerStationCode',
				minWidth: 200,
				search: true,
				display:false
			},
			{
				label: '业主姓名',
				prop: 'customerName',
				minWidth: 100,
				search: true,
				display:false
			},
			{
				label: '联系方式',
				prop: 'customerMobile',
				minWidth: 120,
				search: true,
				display:false
			},
			{
				label: '地址',
				prop: 'customerAddress',
				minWidth: 250,
				search: true,
				display:false
			},
			{
				label: '保修类型',
				prop: 'warrantyType',
				minWidth: 100,
				search: true,
				display:false,
				type: 'select',
				dicUrl: '/blade-system/dict/dictionary?code=warranty_type',
				props: {
					label: 'dictValue',
					value: 'dictKey',
				},
			},
			{
				label: '服务类型',
				prop: 'serviceType',
				minWidth: 100,
				search: true,
				display:false,
				type: 'select',
				dicUrl: '/sf/operationServiceType/list',
				props: {
					label: 'name',
					value: 'id',
				},
			},
			{
				label: '服务措施',
				prop: 'serviceMeasures',
				minWidth: 200,
				search: true,
				display:false,
				type: 'select',
				dicUrl: '/sf/operationServiceMeasures/list',
				props: {
					label: 'serviceMeasures',
					value: 'id',
				},
				dicFormatter:(res)=>{
					return res.data.records
				}
			},
			{
				label: '设备品牌',
				prop: 'applianceBrand',
				minWidth: 100,
				display:false,
			},
			{
				label: '设备型号',
				prop: 'applianceModel',
				minWidth: 100,
				display:false
			},
			{
				label: '故障设备',
				prop: '',
				minWidth: 200,
				display:false
			},
			{
				label: '故障描述',
				prop: 'remarks',
				minWidth: 200,
				display:false
			},
			{
				label: '信息来源',
				prop: 'orderType',
				minWidth: 120,
				display:false,
				type: 'select',
				dicUrl: '/blade-system/dict/dictionary?code=order_type',
				props: {
				  label: 'dictValue',
				  value: 'dictKey',
				},
			},
			{
				label: '代理商',
				prop: '',
				minWidth: 200,
				display:false
			},
			{
				label: '服务工程师',
				prop: 'employeName',
				minWidth: 120,
				display:false,
				search: orderStatus == '1' ? false : true,
				hide: orderStatus == '1' ? true : false
			},
			{
				label: '创建时间',
				prop: 'createTime',
				minWidth: 160,
				search: true,
				display:false,
				type: 'date',
				format: 'YYYY-MM-DD',
				valueFormat: 'YYYY-MM-DD',
				searchSpan: 6,
				searchRange: true,
			},
			{
				label: '预约时间',
				prop: 'promiseTime',
				minWidth: 160,
				display:false,
			},
			{
				label: '时间要求',
				prop: 'promiseLimit',
				minWidth: 160,
				display:false,
				type: 'select',
				dicUrl: '/blade-system/dict/dictionary?code=time_requirements',
				props: {
					label: 'dictValue',
					value: 'dictKey',
				},
			},
			{
				label: '派工时间',
				prop: 'dispatchTime',
				minWidth: 160,
				search: (deptId == '3' || deptId == '5') || orderStatus == '1' || orderStatus == '2' ? false : true,
				display:false,
				type: "date",
				format: 'YYYY-MM-DD',
				valueFormat: 'YYYY-MM-DD',
				searchSpan: 6,
				searchRange: true,
				hide:(deptId == '3' || deptId == '5') || orderStatus == '1' || orderStatus == '2' ? true : false,
			},
			{
				label: '派工时间',
				prop: 'siteDispatchTime',
				minWidth: 160,
				search: (deptId == '3' || deptId == '5') && orderStatus != '1' && orderStatus != '2' ? true : false,
				display:false,
				hide:true,
				type: "date",
				format: 'YYYY-MM-DD',
				valueFormat: 'YYYY-MM-DD',
				searchSpan: 6,
				searchRange: true,
				hide:(deptId == '3' || deptId == '5') && orderStatus != '1' && orderStatus != '2' ? false : true,
			},
			{
				label: '接单时间',
				prop: 'processTime',
				minWidth: 160,
				display:false,
				hide:(deptId == '3' || deptId == '5') || orderStatus == '1' || orderStatus == '2' ? true : false,
			},
			{
				label: '接单时间',
				prop: 'siteProcessTime',
				minWidth: 160,
				display:false,
				hide:(deptId == '3' || deptId == '5') && orderStatus != '1' || orderStatus != '2' ? false : true,
			},
			{
				label: '完工时间',
				prop: 'endTime',
				minWidth: 160,
				search: orderStatus == '1' || orderStatus == '2' ? false : true,
				hide: orderStatus == '1' || orderStatus == '2' ? true : false,
				display:false,
				type: "date",
				format: 'YYYY-MM-DD',
				valueFormat: 'YYYY-MM-DD',
				searchSpan: 6,
				searchRange: true,
			},
			{
				label:'设备类型',
				prop: 'applianceCategory',
				type: 'select',
				dicUrl: '/blade-system/dict/dictionary?code=device_types',
				props: {
					label: 'dictValue',
					value: 'dictKey',
				},
				search: true,
				hide:true,
			},
		],
	}
	vm.option = _option;
	
	var _formOption = {
		labelWidth:100,
		menuPosition:'right',
		gutter:10,
		menuBtn:false,
		detail: vm.title == '详情' ? true : false,
		group:[{
				label:'业主信息',
				arrow: false,
				// display: vm.tabActive == 'second' ? false : true,
				column: [{
						label: '业主姓名',
						prop: 'customerName',
						span:8,
						rules: [
							{
								required: true,
								message: '请输入',
								trigger: 'blur',
							},
						],
					},
					{
						label: '联系方式1',
						prop: 'customerMobile',
						span:8,
						maxlength:11,
						rules: [
							{
								required: true,
								message: '请输入',
								trigger: 'blur',
							},
						],
					},
					{
						label: '联系方式2',
						prop: 'customerTelephone',
						span:8
					},
					{
						label: '省',
						prop: 'province',
						display:false,
					},
					{
						label: '市',
						prop: 'city',
						display:false,
					},
					{
						label: '区',
						prop: 'area',
						display:false,
					},
					{
						label: '安装地址',
						prop: 'provinceCode',
						placeholder:'请选择省',
						span:7,
						type: 'select',
						props: {
							label: 'name',
							value: 'code',
						},
						cascader: ['cityCode'],
						dicUrl: '/blade-system/region/select',
						rules: [{
							required: true,
							message: '请选择',
							trigger: 'change',
						}],
						change:(res)=>{
							vm.formData.provinceCode = res.value;
							if(res&&res.item&&res.item.name){
								vm.formData.province = res.item.name
							}else{
								// vm.formData.province = ''
							}
						},
					},
					{
						label: '',
						prop: 'cityCode',
						placeholder:'请选择市',
						type: 'select',
						props: {
							label: 'name',
							value: 'code',
						},
						cascader: ['areaCode'],
						dicFlag: false,
						dicUrl: '/blade-system/region/select?code={{provinceCode}}',
						span:5,
						labelWidth: 0,
						rules: [{
							required: true,
							message: '请选择',
							trigger: 'change',
						}],
						change:(res)=>{
							vm.formData.cityCode = res.value;
							if(res&&res.item&&res.item.name){
								vm.formData.city = res.item.name
							}else{
								// vm.formData.city = ''
							}
						},
					},
					{
						label: '',
						prop: 'areaCode',
						placeholder:'请选择区',
						type: 'select',
						props: {
							label: 'name',
							value: 'code',
						},
						dicFlag: false,
						dicUrl: '/blade-system/region/select?code={{cityCode}}',
						span:5,
						labelWidth: 0,
						rules: [{
							required: true,
							message: '请选择',
							trigger: 'change',
						}],
						change:(res)=>{
							vm.formData.areaCode = res.value;
							if(res&&res.item&&res.item.name){
								vm.formData.area = res.item.name
							}else{
								// vm.formData.area = ''
							}
						},
					},
					{
						label: '',
						prop: 'customerAddress',
						placeholder:'请输入详细地址',
						span:7,
						labelWidth: 0,
						rules: [{
							required: true,
							message: '请输入',
							trigger: 'blur',
						}],
					},
				]
			},
			{
				label:'工单信息',
				arrow: false,
				// display: vm.tabActive == 'second' ? false : true,
				column:[
					{
						label:'保修类型',
						prop: 'warrantyType',
						span:8,
						type: 'select',
						dicUrl: '/blade-system/dict/dictionary?code=warranty_type',
						props: {
							label: 'dictValue',
							value: 'dictKey',
						},
						rules: [
							{
								required: true,
								message: '请选择',
								trigger: 'change',
							},
						],
					},
					{
						label:'服务类型',
						prop: 'serviceType',
						span:8,
						type: 'select',
						dicUrl: '/sf/operationServiceType/list',
						props: {
							label: 'name',
							value: 'id',
						},
						rules: [
							{
								required: true,
								message: '请选择',
								trigger: 'change',
							},
						],
					},
					{
						label:'服务措施',
						prop: 'serviceMeasures',
						span:8,
						type: 'select',
						dicUrl: '/sf/operationServiceMeasures/list',
						props: {
							label: 'serviceMeasures',
							value: 'id',
						},
						dicFormatter:(res)=>{
							return res.data.records
						}
					},
				]
			},
			{
				label:'电站信息',
				arrow: false,
				// display: vm.tabActive == 'second' ? false : true,
				column:[
					{
						label:'电站编码',
						prop: 'powerStationCode',
						span:8,
					},
					{
						label:'设备类型',
						prop: 'applianceCategory',
						span:8,
						type: 'select',
						dicUrl: '/blade-system/dict/dictionary?code=device_types',
						props: {
							label: 'dictValue',
							value: 'dictKey',
						},
						rules: [
							{
								required: true,
								message: '请选择',
								trigger: 'change',
							},
						],
					},
					{
						label:'设备品牌',
						prop: 'applianceBrand',
						span:8,
						type: 'select',
						display: vm.title == '详情' ? false : true,
						dicUrl: '/sf/operationOrderCallback/getAllBrand',
						props: {
							label: 'name',
							value: 'name',
						},
						dicFormatter:(res)=>{
							return res.data
						}
					},
					{
						label:'设备S/N',
						prop: 'applianceBarcode',
						span:8,
						display: vm.title == '详情' ? false : true,
					},
					{
						label:'代理商',
						prop: 'agentName',
						span:8,
						display: vm.title != '详情' ? false : true,
						// type: 'select',
						// dicUrl: '/sf/operationSite/list',
						// props: {
						//   label: 'name',
						//   value: 'id',
						// },
						// dicFormatter:(res)=>{
						// 	return res.data.records
						// }
					},
					{
						label:'报修时间',
						prop: 'repairTime',
						span:8,
						type: "datetime",
						format: 'YYYY-MM-DD HH:mm:ss',
						valueFormat: 'YYYY-MM-DD HH:mm:ss',
						rules: [
							{
								required: true,
								message: '请选择',
								trigger: 'change',
							},
						],
					},
					{
						label:'预约时间',
						prop: 'promiseTime',
						span:8,
						type: 'date',
						format: 'YYYY-MM-DD',
						valueFormat: 'YYYY-MM-DD',
						disabledDate (time) {
							return time.getTime() < Date.now();
						}
					},
					{
						label:'时间要求',
						prop: 'promiseLimit',
						span:8,
						type: 'select',
						dicUrl: '/blade-system/dict/dictionary?code=time_requirements',
						props: {
							label: 'dictValue',
							value: 'dictKey',
						},
					},
					// {
					// 	label:'订单来源',
					// 	prop: 'orderType',
					// 	span:8,
					// 	type: 'select',
					// 	dicUrl: '/blade-system/dict/dictionary?code=order_type',
					// 	props: {
					// 	  label: 'dictValue',
					// 	  value: 'dictKey',
					// 	},
					// 	rules: [
					// 	  {
					// 	    required: true,
					// 			message: '请选择',
					// 	    trigger: 'change',
					// 	  },
					// 	],
					// },
					{
						label:'故障描述',
						prop: 'remarks',
						span:24,
						type: 'textarea',
						rules: [
							{
								required: true,
								message: '请输入',
								trigger: 'blur',
							},
						],
					},
					{
						label: '故障图片',
						prop: 'bdImgs',
						span:24,
						type: 'upload',
						listType: 'picture-card',
						multiple:true,
						limit:3,
						dataType: 'string',
						action: '/blade-resource/oss/endpoint/put-file?code=aliyun',
						propsHttp: {
							res: 'data',
							url: 'link',
						},
						tip: '最多上传3张图片',
					},
				]
			},
			{
				label:'服务进程',
				arrow: false,
				display: vm.title != '详情' || (deptId == '3' || deptId == '5') ? false : true,
				column:[
					{
						slot:true,
						labelWidth:0,
						prop: 'serviceProcess',
						span:24
					}
				]
			},
			{
				label:'服务信息',
				arrow: false,
				display: vm.title != '详情' ? false : true,
				column:[
					{
						label: '服务工程师',
						prop: 'employeName',
						span:8
					},
					{
						label: '服务状态',
						prop: 'siteStatus',
						span:16,
						type: 'select',
						dicUrl: '/blade-system/dict/dictionary?code=site_order_status',
						props: {
							label: 'dictValue',
							value: 'dictKey',
						},
					},
					{
						label: '过程反馈',
						prop: 'feedback',
						span:24,
						type: 'textarea',
						bind: 'feedbackEntity.feedback',
					},
					{
						label: '反馈图片',
						// prop: 'feedbackImg',
						prop: 'feedImgs',
						span:24,
						type: 'upload',
						listType: 'picture-card',
						// bind: 'feedbackEntity.feedbackImg'
						// multiple:true,
						// limit:3,
						// dataType: 'string',
						// action: '/blade-resource/oss/endpoint/put-file?code=aliyun',
						// propsHttp: {
						// 	res: 'data',
						// 	url: 'link',
						// },
						// tip: '最多上传3张图片',
					},
				]
			},
		]
	}
	vm.formOption = _formOption;
}

