|
@@ -0,0 +1,255 @@
|
|
|
|
+<template>
|
|
|
|
+ <div>
|
|
|
|
+ <el-dialog
|
|
|
|
+ :title="exData.id ? '编辑': '新增'"
|
|
|
|
+ :visible.sync="dialog"
|
|
|
|
+ width="900px"
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
+ top="50px">
|
|
|
|
+ <el-form
|
|
|
|
+ ref="form"
|
|
|
|
+ :model="form"
|
|
|
|
+ :rules="formRules"
|
|
|
|
+ label-width="120px">
|
|
|
|
+ <el-form-item
|
|
|
|
+ prop="rotation_name"
|
|
|
|
+ :rules="formRules.required"
|
|
|
|
+ label="农户姓名:">
|
|
|
|
+ <el-input v-model="form.rotation_name"
|
|
|
|
+ placeholder="请输入农户姓名"
|
|
|
|
+ clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ prop="rotation_name"
|
|
|
|
+ :rules="formRules.required"
|
|
|
|
+ label="身份证号:">
|
|
|
|
+ <el-input v-model="form.rotation_name"
|
|
|
|
+ placeholder="请输入身份证号"
|
|
|
|
+ clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ prop="sort_id"
|
|
|
|
+ :rules="formRules.required"
|
|
|
|
+ label="手机号:">
|
|
|
|
+ <el-input v-model="form.sort_id"
|
|
|
|
+ placeholder="请输入手机号"
|
|
|
|
+ clearable
|
|
|
|
+ @input="form.sort_id = form.sort_id.replace(/[^\d]$/, '').replace(/^0\d/, '')"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ prop="rotation_name"
|
|
|
|
+ :rules="formRules.required"
|
|
|
|
+ label="村信息:">
|
|
|
|
+ <el-input v-model="form.rotation_name"
|
|
|
|
+ placeholder="请输入村信息"
|
|
|
|
+ clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ prop="rotation_name"
|
|
|
|
+ :rules="formRules.required"
|
|
|
|
+ label="微信号:">
|
|
|
|
+ <el-input v-model="form.rotation_name"
|
|
|
|
+ placeholder="请输入微信号"
|
|
|
|
+ clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ prop="rotation_img_url"
|
|
|
|
+ :rules="formRules.uploadImgs"
|
|
|
|
+ label="个人二维码:">
|
|
|
|
+ <el-upload
|
|
|
|
+ :on-remove="handleRemove"
|
|
|
|
+ :on-success="handleAvatarSuccess"
|
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
|
+ :on-exceed="hadnleExceed"
|
|
|
|
+ :accept="'image/*'"
|
|
|
|
+ :limit="1"
|
|
|
|
+ :file-list="fileList"
|
|
|
|
+ list-type="picture-card"
|
|
|
|
+ action="/api/admin/v1/upload/file"
|
|
|
|
+ multiple>
|
|
|
|
+ <i class="el-icon-plus"></i>
|
|
|
|
+ <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过5M</div>
|
|
|
|
+ </el-upload>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ prop="rotation_name"
|
|
|
|
+ :rules="formRules.required"
|
|
|
|
+ label="详细地址:">
|
|
|
|
+ <el-input v-model="form.rotation_name"
|
|
|
|
+ placeholder="请输入详细地址"
|
|
|
|
+ clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="备注:"
|
|
|
|
+ prop="rotation_url"
|
|
|
|
+ v-show="form.rotation_link_type !== 1">
|
|
|
|
+ <el-input type="textarea"
|
|
|
|
+ :rows="4"
|
|
|
|
+ placeholder="上限200字符"
|
|
|
|
+ maxlength="200"
|
|
|
|
+ show-word-limit
|
|
|
|
+ v-model="form.rotation_url">
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <div slot="footer" class="dialog-footer text-center">
|
|
|
|
+ <el-button @click="dialog = false">取 消</el-button>
|
|
|
|
+ <el-button type="primary" :disabled="booLock" @click="handleSubmit">确 定</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import { yuan2Fen, fen2Yuan } from '@/utils'
|
|
|
|
+
|
|
|
|
+export default {
|
|
|
|
+ props: {
|
|
|
|
+ value: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: true
|
|
|
|
+ },
|
|
|
|
+ exData: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default: function () {
|
|
|
|
+ return {}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ dialog: !!this.value,
|
|
|
|
+ form: {
|
|
|
|
+ 'rotation_img_url': [], // 轮播图片地址
|
|
|
|
+ 'rotation_status': '', // 轮播图状态(0无效1有效)
|
|
|
|
+ 'rotation_url': '', // 链接
|
|
|
|
+ 'rotation_name': '', // 轮播图名称
|
|
|
|
+ 'sort_id': '', // 排序ID
|
|
|
|
+ 'rotation_type': '', // 轮播类型(1首页2直播间)
|
|
|
|
+ 'rotation_channel': '', // 应用包
|
|
|
|
+ 'rotation_link_type': ''
|
|
|
|
+ },
|
|
|
|
+ fileList: [],
|
|
|
|
+ booLock: false
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ arrRotationType() {
|
|
|
|
+ return []
|
|
|
|
+ },
|
|
|
|
+ arrRotationStatus() {
|
|
|
|
+ return []
|
|
|
|
+ },
|
|
|
|
+ rotationChannelList() {
|
|
|
|
+ return []
|
|
|
|
+ },
|
|
|
|
+ arrRotationLinkType() {
|
|
|
|
+ return []
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ beforeAvatarUpload(file) {
|
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 5
|
|
|
|
+ if (!isLt2M) {
|
|
|
|
+ this.$message.error('上传图片大小不能超过 5MB!')
|
|
|
|
+ }
|
|
|
|
+ return isLt2M
|
|
|
|
+ },
|
|
|
|
+ handleRemove(file) {
|
|
|
|
+ let path = file.url
|
|
|
|
+ if (file.response && file.response.data) {
|
|
|
|
+ path = file.response.data.path
|
|
|
|
+ }
|
|
|
|
+ this.form.rotation_img_url = this.form.rotation_img_url.filter(item => item !== path)
|
|
|
|
+ },
|
|
|
|
+ handleAvatarSuccess(res) {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ const { path } = res.data
|
|
|
|
+ this.form.rotation_img_url.push(path)
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error('图片上传失败')
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ hadnleExceed(files, fileList) {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '最多上传一张',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ handleSubmit() {
|
|
|
|
+ const url = this.exData.id ? '/v1/setting/rotation/modify' : '/v1/setting/rotation/add'
|
|
|
|
+ this.$refs.form.validate(async valid => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ const formData = JSON.parse(JSON.stringify(this.form))
|
|
|
|
+ const postData = {
|
|
|
|
+ ...formData,
|
|
|
|
+ rotation_img_url: formData.rotation_img_url[0]
|
|
|
|
+ }
|
|
|
|
+ if (this.form.rotation_link_type === 1) {
|
|
|
|
+ postData.rotation_url = ''
|
|
|
|
+ }
|
|
|
|
+ this.booLock = true
|
|
|
|
+ const data = await this.$fetch(url, postData)
|
|
|
|
+ this.booLock = false
|
|
|
|
+ if (data.code === 200) {
|
|
|
|
+ this.$message.success('提交成功')
|
|
|
|
+ this.$emit('success')
|
|
|
|
+ this.dialog = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ if (this.exData.id) {
|
|
|
|
+ this.$set(this.form, 'id', this.exData.id)
|
|
|
|
+ this.fileList = [
|
|
|
|
+ {
|
|
|
|
+ name: '',
|
|
|
|
+ url: this.exData.rotation_img_url
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ for (const key in this.exData) {
|
|
|
|
+ if (this.form.hasOwnProperty(key)) {
|
|
|
|
+ let value = this.exData[key]
|
|
|
|
+ if ((Array.isArray(value) && value.length >= 1) || (Object.prototype.toString.call(value) === '[object Object]') || (typeof value === 'string' && value) || typeof value === 'number') {
|
|
|
|
+ if (key === 'rotation_img_url') {
|
|
|
|
+ value = [value]
|
|
|
|
+ }
|
|
|
|
+ if (key === 'sort_id') {
|
|
|
|
+ value = value.toString()
|
|
|
|
+ }
|
|
|
|
+ this.$set(this.form, key, value)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ dialog(val) {
|
|
|
|
+ if (!val) this.$emit('input', val)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+.top-tip {
|
|
|
|
+ margin-top: -20px;
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.af-put-line-radio {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+
|
|
|
|
+ p.lalel {
|
|
|
|
+ padding: 0 10px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ p {
|
|
|
|
+ padding: 0;
|
|
|
|
+ margin: 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|