|
@@ -12,120 +12,88 @@
|
|
|
:rules="formRules"
|
|
|
label-width="120px">
|
|
|
<el-form-item
|
|
|
- prop="rotation_channel"
|
|
|
- :rules="formRules.select"
|
|
|
- label="应用包:">
|
|
|
- <el-select
|
|
|
- style="width: 100%;"
|
|
|
- v-model="form.rotation_channel"
|
|
|
- filterable
|
|
|
- clearable
|
|
|
- placeholder="请选择应用包">
|
|
|
- <el-option
|
|
|
- v-for="item in rotationChannelList"
|
|
|
- :key="item.rotation_channel"
|
|
|
- :label="item.rotation_name"
|
|
|
- :value="item.rotation_channel">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item
|
|
|
- prop="rotation_type"
|
|
|
- :rules="formRules.select"
|
|
|
- label="轮播图类型:">
|
|
|
- <el-select
|
|
|
- style="width: 100%;"
|
|
|
- v-model="form.rotation_type"
|
|
|
- filterable
|
|
|
+ prop="sort_id"
|
|
|
+ :rules="formRules.required"
|
|
|
+ label="排序:">
|
|
|
+ <el-input
|
|
|
+ v-model="form.sort_id"
|
|
|
+ placeholder="请输入排序值"
|
|
|
clearable
|
|
|
- placeholder="请选择轮播图类型">
|
|
|
- <el-option
|
|
|
- :label="item.name"
|
|
|
- :value="item.value"
|
|
|
- v-for="item in arrRotationType"
|
|
|
- :key="item.value"></el-option>
|
|
|
- </el-select>
|
|
|
+ @input="form.sort_id = form.sort_id.replace(/[^\d]$/, '').replace(/^0\d/, '0')"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
|
- prop="rotation_name"
|
|
|
+ prop="lunbo_name"
|
|
|
:rules="formRules.required"
|
|
|
label="标题:">
|
|
|
- <el-input v-model="form.rotation_name"
|
|
|
- placeholder="请输入标题"
|
|
|
- clearable></el-input>
|
|
|
+ <el-input
|
|
|
+ v-model="form.lunbo_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/, '0')"></el-input>
|
|
|
+ prop="lunbo_img_url"
|
|
|
+ :rules="formRules.uploadImgs"
|
|
|
+ label="图片:">
|
|
|
+ <el-upload
|
|
|
+ :on-remove="(file) => {handleRemove(file, 'lunbo_img_url')}"
|
|
|
+ :on-success="(file) => {handleAvatarSuccess(file, 'lunbo_img_url')}"
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
+ :on-exceed="hadnleExceed"
|
|
|
+ :accept="'image/*'"
|
|
|
+ :limit="1"
|
|
|
+ :file-list="lunbo_img_url"
|
|
|
+ list-type="picture-card"
|
|
|
+ action="/api/upload/img"
|
|
|
+ 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_status"
|
|
|
+ prop="lunbo_status"
|
|
|
:rules="formRules.select"
|
|
|
- label="是否显示:">
|
|
|
+ label="状态:">
|
|
|
<el-select
|
|
|
style="width: 100%;"
|
|
|
- v-model="form.rotation_status"
|
|
|
+ v-model="form.lunbo_status"
|
|
|
filterable
|
|
|
clearable
|
|
|
placeholder="请选择是否显示">
|
|
|
<el-option
|
|
|
:label="item.name"
|
|
|
:value="item.value"
|
|
|
- v-for="item in arrRotationStatus"
|
|
|
+ v-for="item in arrLunboStatus"
|
|
|
:key="item.value"></el-option>
|
|
|
</el-select>
|
|
|
</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_link_type"
|
|
|
+ prop="lunbo_link_type"
|
|
|
:rules="formRules.select"
|
|
|
label="链接类型:">
|
|
|
<el-select
|
|
|
style="width: 100%;"
|
|
|
- v-model="form.rotation_link_type"
|
|
|
+ v-model="form.lunbo_link_type"
|
|
|
filterable
|
|
|
clearable
|
|
|
placeholder="请选择链接类型">
|
|
|
<el-option
|
|
|
:label="item.name"
|
|
|
:value="item.value"
|
|
|
- v-for="item in arrRotationLinkType"
|
|
|
+ v-for="item in arrLunboLinkType"
|
|
|
:key="item.value"></el-option>
|
|
|
</el-select>
|
|
|
</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">
|
|
|
+ prop="lunbo_link_url"
|
|
|
+ v-show="form.lunbo_link_type !== 2">
|
|
|
+ <el-input
|
|
|
+ type="textarea"
|
|
|
+ :rows="4"
|
|
|
+ placeholder="上限200字符"
|
|
|
+ maxlength="200"
|
|
|
+ show-word-limit
|
|
|
+ v-model="form.lunbo_link_url">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
@@ -138,8 +106,6 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { yuan2Fen, fen2Yuan } from '@/utils'
|
|
|
-
|
|
|
export default {
|
|
|
props: {
|
|
|
value: {
|
|
@@ -157,31 +123,24 @@ export default {
|
|
|
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': ''
|
|
|
+ 'sort_id': '', // 排序
|
|
|
+ 'lunbo_name': '', // 轮播图名称
|
|
|
+ 'lunbo_img_url': [], // 轮播图片
|
|
|
+ 'lunbo_status': '', // 状态(0下架1上架)
|
|
|
+ 'lunbo_link_type': '', // 链接类型(0外链1小程序)
|
|
|
+ 'lunbo_link_url': '' // 跳转地址
|
|
|
+
|
|
|
},
|
|
|
- fileList: [],
|
|
|
+ lunbo_img_url: [],
|
|
|
booLock: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- arrRotationType() {
|
|
|
- return this.$store.state.common.arrRotationType
|
|
|
+ arrLunboStatus() {
|
|
|
+ return this.$store.state.common.arrLunboStatus
|
|
|
},
|
|
|
- arrRotationStatus() {
|
|
|
- return this.$store.state.common.arrRotationStatus
|
|
|
- },
|
|
|
- rotationChannelList() {
|
|
|
- return this.$store.state.common.rotationChannelList
|
|
|
- },
|
|
|
- arrRotationLinkType() {
|
|
|
- return this.$store.state.common.arrRotationLinkType
|
|
|
+ arrLunboLinkType() {
|
|
|
+ return this.$store.state.common.arrLunboLinkType
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -192,17 +151,17 @@ export default {
|
|
|
}
|
|
|
return isLt2M
|
|
|
},
|
|
|
- handleRemove(file) {
|
|
|
+ handleRemove(file, formkey) {
|
|
|
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)
|
|
|
+ this.form[formkey] = this.form[formkey].filter(item => item !== path)
|
|
|
},
|
|
|
- handleAvatarSuccess(res) {
|
|
|
+ handleAvatarSuccess(res, formkey) {
|
|
|
if (res.code === 200) {
|
|
|
const { path } = res.data
|
|
|
- this.form.rotation_img_url.push(path)
|
|
|
+ this.form[formkey].push(path)
|
|
|
} else {
|
|
|
this.$message.error('图片上传失败')
|
|
|
}
|
|
@@ -214,16 +173,16 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
handleSubmit() {
|
|
|
- const url = this.exData.id ? '/v1/setting/rotation/modify' : '/v1/setting/rotation/add'
|
|
|
+ const url = this.exData.id ? '/api/admin/tlunbo/modify' : '/api/admin/tlunbo/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]
|
|
|
+ lunbo_img_url: formData.lunbo_img_url[0]
|
|
|
}
|
|
|
- if (this.form.rotation_link_type === 1) {
|
|
|
- postData.rotation_url = ''
|
|
|
+ if (this.form.lunbo_link_type === 2) {
|
|
|
+ postData.lunbo_link_url = ''
|
|
|
}
|
|
|
this.booLock = true
|
|
|
const data = await this.$fetch(url, postData)
|
|
@@ -238,22 +197,19 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- if (!(this.rotationChannelList.length)) {
|
|
|
- this.$store.dispatch('common/getRotationChannelList')
|
|
|
- }
|
|
|
if (this.exData.id) {
|
|
|
this.$set(this.form, 'id', this.exData.id)
|
|
|
- this.fileList = [
|
|
|
+ this.lunbo_img_url = [
|
|
|
{
|
|
|
name: '',
|
|
|
- url: this.exData.rotation_img_url
|
|
|
+ url: this.exData.lunbo_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') {
|
|
|
+ if (key === 'lunbo_img_url') {
|
|
|
value = [value]
|
|
|
}
|
|
|
if (key === 'sort_id') {
|