| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <el-dialog
- :title="!dataForm.id ? this.$i18n.t('crud.addTitle') : this.$i18n.t('temp.modify')"
- :close-on-click-modal="false"
- :visible.sync="visible">
- <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="80px">
- <el-row>
- <el-col :span="10">
- <el-form-item label="推广人" prop="tgUserName" :rules="{required: true, message: '推广人必填', trigger: 'blur'}" size="small">
- <el-input v-model="dataForm.tgUserName"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="10" :offset="1">
- <el-form-item label="推广店铺" prop="shopId" :rules="{required: true, message: '推广店铺必填', trigger: 'blur'}" size="small">
- <el-select v-model="dataForm.shopId" placeholder="推广店铺" style="width: 330px" @change="shopChange"
- controls-position="right" :clearable="true">
- <el-option v-for="(item,index) in shopList" :key="index" :label="item.shopName" :value="item.shopId">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="博主ID" prop="upId" size="small">
- <el-input v-model="dataForm.upId"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="10" :offset="1">
- <el-form-item label="博主名称" prop="upName" :rules="{required: true, message: '博主昵称必填', trigger: 'blur'}" size="small">
- <el-input v-model="dataForm.upName"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="视频平台" prop="publishPlatform" size="small">
- <el-autocomplete
- class="inline-input"
- v-model="dataForm.publishPlatform"
- :fetch-suggestions="querySearch"
- placeholder="请输入内容"
- style="width :330px;">
- <template slot-scope="{ item }">
- <div class="name">{{ item.label }}</div>
- </template>
- </el-autocomplete>
- </el-form-item>
- </el-col>
- <el-col :span="10" :offset="1">
- <el-form-item label="粉丝数" prop="fansNum" size="small">
- <el-input v-model="dataForm.fansNum" type="number"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button class="default-btn" @click="visible = false">{{$t("crud.filter.cancelBtn")}}</el-button>
- <el-button class="default-btn primary-btn" type="primary" @click="dataFormSubmit()">{{$t("crud.filter.submitBtn")}}</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- export default {
- data () {
- return {
- visible: false,
- dataForm: {
- id: null,
- upId: null,
- upName: null,
- publishPlatform: null,
- fansNum: null,
- tgUserName: null,
- shopId: this.$store.state.user.shopId,
- shopName: null
- },
- dataRule: {
- },
- shopList:[],
- videoPlatformList: [
- {value: '抖音', label: '抖音'},
- {value: '小红书', label: '小红书'},
- {value: '视频号', label: '视频号'},
- {value: '快手', label: '快手'},
- {value: 'B站', label: 'B站'},
- ],
- }
- },
- mounted() {
- this.getShopList()
- },
- methods: {
- init (id) {
- this.dataForm.id = id || 0
- this.visible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].resetFields()
- if (this.dataForm.id) {
- this.$http({
- url: this.$http.adornUrl('/promotion/promotionUp/info/' + this.dataForm.id),
- method: 'get',
- params: this.$http.adornParams()
- }).then(({data}) => {
- this.dataForm = data
- })
- }
- })
- },
- shopChange (index) {
- this.dataForm.shopName = this.shopList[index].shopName
- },
- getShopList() {
- this.$http({
- url: this.$http.adornUrl('/platform/shopDetail/getShopList'),
- method: 'get',
- params: this.$http.adornParams({})
- }).then(({ data }) => {
- if (data) {
- this.shopList = data
- }
- })
- },
- querySearch (queryString, cb) {
- var restaurants = this.videoPlatformList
- var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants
- // 调用 callback 返回建议列表的数据
- cb(results)
- },
- createFilter (queryString) {
- return (restaurant) => {
- return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
- }
- },
- // 表单提交
- dataFormSubmit () {
- this.$refs['dataForm'].validate((valid) => {
- if (valid) {
- this.dataForm.shopName = this.shopList.find(item => item.shopId === this.dataForm.shopId).shopName
- this.$http({
- url: this.$http.adornUrl('/promotion/promotionUp'),
- method: this.dataForm.id ? 'put' : 'post',
- data: this.$http.adornData(this.dataForm)
- }).then(({data}) => {
- this.$message({
- message: this.$i18n.t('publics.operation'),
- type: 'success',
- duration: 200,
- onClose: () => {
- this.visible = false
- this.$emit('refreshDataList')
- }
- })
- })
- }
- })
- }
- }
- }
- </script>
|