|  | @@ -0,0 +1,178 @@
 | 
	
		
			
				|  |  | +<template>
 | 
	
		
			
				|  |  | +    <zz-form :cols="formCols" :data="formData" :rules="formRules" labelWidth="90" ref="form">
 | 
	
		
			
				|  |  | +        <template slot="communityId">
 | 
	
		
			
				|  |  | +            <el-select class="width65" v-model="formData.communityId" clearable>
 | 
	
		
			
				|  |  | +                <el-option
 | 
	
		
			
				|  |  | +                    :label="item.communityName"
 | 
	
		
			
				|  |  | +                    :value="item.id"
 | 
	
		
			
				|  |  | +                    v-for="item in $store.getters['getAreaSelect']"
 | 
	
		
			
				|  |  | +                    :key="item.id"
 | 
	
		
			
				|  |  | +                ></el-option>
 | 
	
		
			
				|  |  | +            </el-select>
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +        <template slot="orderType">
 | 
	
		
			
				|  |  | +            <el-select class="width65" v-model="formData.orderType" clearable>
 | 
	
		
			
				|  |  | +                <el-option label="业主报修" :value="1"></el-option>
 | 
	
		
			
				|  |  | +                <el-option label="内部报修" :value="2"></el-option>
 | 
	
		
			
				|  |  | +            </el-select>
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +        <template slot="repairFile">
 | 
	
		
			
				|  |  | +            <el-upload
 | 
	
		
			
				|  |  | +                :headers="token"
 | 
	
		
			
				|  |  | +                ref="uploaduserlogo"
 | 
	
		
			
				|  |  | +                class="mini-upload"
 | 
	
		
			
				|  |  | +                limit="3"
 | 
	
		
			
				|  |  | +                list-type="picture-card"
 | 
	
		
			
				|  |  | +                action="/sc-community/upload/uploadFile"
 | 
	
		
			
				|  |  | +                :on-success="uploadsuccess"
 | 
	
		
			
				|  |  | +                :before-upload="beforeAvatarUpload"
 | 
	
		
			
				|  |  | +                :auto-upload="true"
 | 
	
		
			
				|  |  | +                name="file"
 | 
	
		
			
				|  |  | +            >
 | 
	
		
			
				|  |  | +                <i slot="default" class="el-icon-plus"></i>
 | 
	
		
			
				|  |  | +            </el-upload>
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +    </zz-form>
 | 
	
		
			
				|  |  | +</template>
 | 
	
		
			
				|  |  | +<script >
 | 
	
		
			
				|  |  | +export default {
 | 
	
		
			
				|  |  | +    props: ['params'],
 | 
	
		
			
				|  |  | +    data() {
 | 
	
		
			
				|  |  | +        return {
 | 
	
		
			
				|  |  | +            token: {
 | 
	
		
			
				|  |  | +                [localStorage.getItem('UMIS_token') && 'Authorization']: 'Bearer ' + localStorage.getItem('UMIS_token')
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            formData: {
 | 
	
		
			
				|  |  | +                communityId: '',
 | 
	
		
			
				|  |  | +                orderType: '',
 | 
	
		
			
				|  |  | +                address: '',
 | 
	
		
			
				|  |  | +                repairName: '',
 | 
	
		
			
				|  |  | +                repairPhone: '',
 | 
	
		
			
				|  |  | +                repairContent: ''
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            formRules: {
 | 
	
		
			
				|  |  | +                communityId: [this.$valid.selectRequired('社区')],
 | 
	
		
			
				|  |  | +                orderType: [this.$valid.selectRequired('工单类型')],
 | 
	
		
			
				|  |  | +                address: this.$valid.custome({
 | 
	
		
			
				|  |  | +                    validator(rule, value, cb) {
 | 
	
		
			
				|  |  | +                        const rl = rule;
 | 
	
		
			
				|  |  | +                        let regExp = /^.{1,20}$/;
 | 
	
		
			
				|  |  | +                        if (!value) {
 | 
	
		
			
				|  |  | +                            rl.message = '请输入地址';
 | 
	
		
			
				|  |  | +                            cb(new Error());
 | 
	
		
			
				|  |  | +                        } else if (!regExp.test(value)) {
 | 
	
		
			
				|  |  | +                            rl.message = '不能超过20个字';
 | 
	
		
			
				|  |  | +                            cb(new Error());
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            cb();
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }),
 | 
	
		
			
				|  |  | +                repairName: this.$valid.custome({
 | 
	
		
			
				|  |  | +                    validator(rule, value, cb) {
 | 
	
		
			
				|  |  | +                        const rl = rule;
 | 
	
		
			
				|  |  | +                        let regExp = /^.{1,20}$/;
 | 
	
		
			
				|  |  | +                        if (!value) {
 | 
	
		
			
				|  |  | +                            rl.message = '请输入报修人';
 | 
	
		
			
				|  |  | +                            cb(new Error());
 | 
	
		
			
				|  |  | +                        } else if (!regExp.test(value)) {
 | 
	
		
			
				|  |  | +                            rl.message = '不能超过20个字';
 | 
	
		
			
				|  |  | +                            cb(new Error());
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            cb();
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }),
 | 
	
		
			
				|  |  | +                repairPhone: [this.$valid.inputRequired('电话')],
 | 
	
		
			
				|  |  | +                repairContent: [this.$valid.inputRequired('报修内容')]
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            formCols: [
 | 
	
		
			
				|  |  | +                [
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        label: '所属社区',
 | 
	
		
			
				|  |  | +                        prop: 'communityId',
 | 
	
		
			
				|  |  | +                        slot: 'communityId'
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        label: '工单类型',
 | 
	
		
			
				|  |  | +                        prop: 'orderType',
 | 
	
		
			
				|  |  | +                        slot: 'orderType'
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        label: '地址',
 | 
	
		
			
				|  |  | +                        prop: 'address',
 | 
	
		
			
				|  |  | +                        input: true
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        label: '报修人',
 | 
	
		
			
				|  |  | +                        prop: 'repairName',
 | 
	
		
			
				|  |  | +                        input: true
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        label: '电话',
 | 
	
		
			
				|  |  | +                        prop: 'repairPhone',
 | 
	
		
			
				|  |  | +                        input: true
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        label: ' 报修内容',
 | 
	
		
			
				|  |  | +                        prop: 'repairContent',
 | 
	
		
			
				|  |  | +                        maxlength: '200',
 | 
	
		
			
				|  |  | +                        rows: 4,
 | 
	
		
			
				|  |  | +                        textarea: true
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        label: ' 图片/视频',
 | 
	
		
			
				|  |  | +                        prop: 'repairFile',
 | 
	
		
			
				|  |  | +                        slot: 'repairFile'
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                ]
 | 
	
		
			
				|  |  | +            ],
 | 
	
		
			
				|  |  | +            token: {
 | 
	
		
			
				|  |  | +                [localStorage.getItem('SC_token') && 'Authorization']: 'Bearer ' + localStorage.getItem('SC_token')
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    methods: {
 | 
	
		
			
				|  |  | +        submit() {
 | 
	
		
			
				|  |  | +            new Promise((resolve) => {
 | 
	
		
			
				|  |  | +                this.$refs.form.validate(resolve);
 | 
	
		
			
				|  |  | +            }).then(() => {
 | 
	
		
			
				|  |  | +                var loading = this.$loading();
 | 
	
		
			
				|  |  | +                let url = '/sc-community/workOrder/add';
 | 
	
		
			
				|  |  | +                this.$http
 | 
	
		
			
				|  |  | +                    .post(url, this.formData)
 | 
	
		
			
				|  |  | +                    .then(({ status, msg }) => {
 | 
	
		
			
				|  |  | +                        if (status == 0) {
 | 
	
		
			
				|  |  | +                            this.$message.success(msg);
 | 
	
		
			
				|  |  | +                            this.params.callback();
 | 
	
		
			
				|  |  | +                            this.$emit('close');
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            this.$message.error(msg);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        loading.close();
 | 
	
		
			
				|  |  | +                    })
 | 
	
		
			
				|  |  | +                    .catch(() => {
 | 
	
		
			
				|  |  | +                        loading.close();
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        uploadsuccess(response, file, fileList) {
 | 
	
		
			
				|  |  | +            this.$refs.uploaduserlogo.clearFiles();
 | 
	
		
			
				|  |  | +            if (0 === response.status) {
 | 
	
		
			
				|  |  | +                this.formData.repairFile = response.data;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        beforeAvatarUpload(file) {
 | 
	
		
			
				|  |  | +            // const isJPG = file.type === 'image/jpeg';
 | 
	
		
			
				|  |  | +            // const isLt2M = file.size / 1024 / 1024 < 2;
 | 
	
		
			
				|  |  | +            // if (!isLt2M) {
 | 
	
		
			
				|  |  | +            //     this.$message.error('上传头像图片大小不能超过 2MB!');
 | 
	
		
			
				|  |  | +            // }
 | 
	
		
			
				|  |  | +            // return isJPG && isLt2M;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    created() {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +</script>
 |