promotionVideo-add-or-update.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <el-dialog
  3. :title="!dataForm.id ? this.$i18n.t('crud.addTitle') : this.$i18n.t('temp.modify')"
  4. :close-on-click-modal="false"
  5. :modal-append-to-body="false"
  6. :visible.sync="visible"
  7. top="1vh"
  8. @close="closeDialog">
  9. <el-row>
  10. <el-col :span="24">
  11. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="110px">
  12. <!-- <el-form-item label="" prop="id">-->
  13. <!-- <el-input v-model="dataForm.id"size="small"></el-input>-->
  14. <!-- </el-form-item>-->
  15. <el-row>
  16. <el-col :span="10">
  17. <el-form-item label="推广人" prop="tgUserName">
  18. <el-input v-model="dataForm.tgUserName"size="small"></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="10" :offset="1">
  22. <el-form-item label="推广店铺" prop="shopId">
  23. <el-select v-model="dataForm.shopId" placeholder="推广店铺"
  24. controls-position="right" :clearable="true" style="width: 295px">
  25. <el-option v-for="item in shopList" :key="item.shopId" :label="item.shopName" :value="item.shopId">
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. </el-row>
  31. <el-row>
  32. <el-col :span="10">
  33. <el-form-item label="博主ID" prop="upId">
  34. <el-input v-model="dataForm.upId"size="small"></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="10" :offset="1">
  38. <el-form-item label="博主昵称" prop="upName">
  39. <el-input v-model="dataForm.upName"size="small"></el-input>
  40. </el-form-item>
  41. </el-col>
  42. </el-row>
  43. <el-row>
  44. <el-col :span="21">
  45. <el-form-item label="视频链接" prop="videoUrl">
  46. <el-input v-model="dataForm.videoUrl"size="small" type="textarea" rows="3"></el-input>
  47. </el-form-item>
  48. </el-col>
  49. </el-row>
  50. <el-row>
  51. <el-col :span="10">
  52. <el-form-item label="t+1点赞数" prop="likeNumT1">
  53. <el-input v-model="dataForm.likeNumT1"size="small"></el-input>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="10" :offset="1">
  57. <el-form-item label="t+7点赞数" prop="likeNumT7">
  58. <el-input v-model="dataForm.likeNumT7"size="small"></el-input>
  59. </el-form-item>
  60. </el-col>
  61. </el-row>
  62. <el-row>
  63. <el-col :span="10">
  64. <el-form-item label="t+1播放数" prop="playNumT1">
  65. <el-input v-model="dataForm.playNumT1"size="small"></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="10" :offset="1">
  69. <el-form-item label="t+7播放数" prop="playNumT7">
  70. <el-input v-model="dataForm.playNumT7"size="small"></el-input>
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. <el-row>
  75. <el-col :span="10">
  76. <el-form-item label="发布平台" prop="publishPlatform">
  77. <el-autocomplete style="width:300px"
  78. class="inline-input"
  79. v-model="dataForm.publishPlatform"
  80. :fetch-suggestions="querySearch"
  81. placeholder="请输入内容">
  82. <template slot-scope="{ item }">
  83. <div class="name">{{ item.label }}</div>
  84. </template>
  85. </el-autocomplete>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="10" :offset="1">
  89. <el-form-item label="粉丝数" prop="fansNum">
  90. <el-input v-model="dataForm.fansNum"size="small"></el-input>
  91. </el-form-item>
  92. </el-col>
  93. </el-row>
  94. <el-row>
  95. <el-col :span="7">
  96. <el-form-item label="评论数" prop="commNum">
  97. <el-input v-model="dataForm.commNum"size="small"></el-input>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="7">
  101. <el-form-item label="点赞数" prop="likeNum">
  102. <el-input v-model="dataForm.likeNum"size="small"></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="7">
  106. <el-form-item label="播放数" prop="playNum">
  107. <el-input v-model="dataForm.playNum"size="small"></el-input>
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. <el-row>
  112. <el-col :span="10">
  113. <el-form-item label="寄拍付费" prop="payType">
  114. <el-select v-model="dataForm.payType" placeholder="请选择" size="small" style="width: 295px;">
  115. <el-option :key="0" label="寄拍" value="寄拍"></el-option>
  116. <el-option :key="1" label="付费 " value="付费"></el-option>
  117. </el-select>
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="10" :offset="1">
  121. <el-form-item label="付费金额" prop="payAmt">
  122. <el-input v-model="dataForm.payAmt"size="small" type="number"></el-input>
  123. </el-form-item>
  124. </el-col>
  125. </el-row>
  126. <el-row>
  127. <el-col :span="10">
  128. <el-form-item label="发布状态" prop="status">
  129. <el-select v-model="dataForm.status" placeholder="请选择" size="small" style="width: 295px">
  130. <el-option :key="1" label="待发布" value="待发布"></el-option>
  131. <el-option :key="2" label="已发布 " value="已发布"></el-option>
  132. </el-select>
  133. </el-form-item>
  134. </el-col>
  135. <el-col :span="10" :offset="1">
  136. <el-form-item label="结算状态" prop="settleStatus">
  137. <el-select v-model="dataForm.settleStatus" placeholder="请选择" size="small" style="width: 295px;">
  138. <el-option :key="1" label="待结算" value="待结算"></el-option>
  139. <el-option :key="2" label="已结算 " value="已结算"></el-option>
  140. </el-select>
  141. </el-form-item>
  142. </el-col>
  143. </el-row>
  144. <el-row>
  145. <el-col :span="10">
  146. <el-form-item label="发布时间" prop="publishTime">
  147. <el-date-picker
  148. style="width: 295px"
  149. size="small"
  150. v-model="dataForm.publishTime"
  151. type="datetime"
  152. value-format="yyyy-MM-dd HH:mm:ss"
  153. placeholder="选择日期时间"
  154. default-time="12:00:00">
  155. </el-date-picker>
  156. </el-form-item>
  157. </el-col>
  158. <el-col :span="10" :offset="1">
  159. <el-form-item label="B站bv号" prop="bvid">
  160. <el-input v-model="dataForm.bvid"size="small"></el-input>
  161. </el-form-item>
  162. </el-col>
  163. </el-row>
  164. <el-row>
  165. <el-form-item label="相关图片" prop="pic">
  166. <el-upload
  167. :disabled="isView"
  168. ref="upload"
  169. :multiple="true"
  170. :action="$http.adornUrl('/admin/file/simpleUpload')"
  171. list-type="picture-card"
  172. :headers="{Authorization: $cookie.get('Authorization_vs'),locale:lang}"
  173. :on-success="onUploadSuccess"
  174. :file-list="fileList"
  175. :limit="1"
  176. :on-remove="handlePicRemove"
  177. :on-preview="handlePicPreview">
  178. <i class="el-icon-plus"></i>
  179. </el-upload>
  180. <div @paste="pasteImg($event)">
  181. <textarea placeholder="点击这里,然后把图片粘贴" style="width: 100%;height: 100px;border: 1px solid #c9c9c9;border-radius: 5px;"></textarea>
  182. </div>
  183. </el-form-item>
  184. </el-row>
  185. </el-form>
  186. </el-col>
  187. </el-row>
  188. <span slot="footer" class="dialog-footer">
  189. <el-button class="default-btn" @click="visible = false">{{$t("crud.filter.cancelBtn")}}</el-button>
  190. <el-button class="default-btn primary-btn" type="primary" @click="dataFormSubmit()">{{$t("crud.filter.submitBtn")}}</el-button>
  191. </span>
  192. </el-dialog>
  193. </template>
  194. <script>
  195. import { uploadFile } from '@/utils/httpRequest.js'
  196. export default {
  197. data () {
  198. return {
  199. visible: false,
  200. isView: false,
  201. lang: localStorage.getItem('lang') || 'zh_CN',
  202. dataForm: {
  203. id: null,
  204. tgUserName: null,
  205. upId: null,
  206. upName: null,
  207. videoUrl: null,
  208. likeNumT1: null,
  209. playNumT1: null,
  210. commNum: null,
  211. likeNumT7: null,
  212. playNumT7: null,
  213. shopId: this.$store.state.user.shopId,
  214. shopName: null,
  215. publishPlatform: null,
  216. payType: null,
  217. payAmt: null,
  218. settleStatus: null,
  219. createTime: null,
  220. updateTime: null,
  221. playNum: null,
  222. likeNum: null,
  223. status: null,
  224. publishTime:null,
  225. pic:null
  226. },
  227. dataRule: {
  228. },
  229. imgDialogVisible: false,
  230. shopList: [],
  231. fileList:[],
  232. resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
  233. videoPlatformList: [
  234. {value: '抖音', label: '抖音'},
  235. {value: '小红书', label: '小红书'},
  236. {value: '视频号', label: '视频号'},
  237. {value: '快手', label: '快手'},
  238. {value: 'B站', label: 'B站'},
  239. ],
  240. }
  241. },
  242. mounted () {
  243. this.getShopList()
  244. },
  245. methods: {
  246. init (id) {
  247. this.dataForm.id = id || 0
  248. this.visible = true
  249. this.$nextTick(() => {
  250. this.$refs['dataForm'].resetFields()
  251. if (this.dataForm.id) {
  252. this.$http({
  253. url: this.$http.adornUrl('/promotion/promotionVideo/info/' + this.dataForm.id),
  254. method: 'get',
  255. params: this.$http.adornParams()
  256. }).then(({data}) => {
  257. this.dataForm = data
  258. if(this.dataForm.pic) {
  259. this.fileList = [];
  260. let picArray = this.dataForm.pic.split(",");
  261. for (let i = 0; i < picArray.length; i++) {
  262. this.fileList.push({ url: this.resourcesUrl + picArray[i], response: {filePath: picArray[i] }})
  263. }
  264. }
  265. })
  266. }
  267. })
  268. },
  269. closeDialog(){
  270. this.fileList = []
  271. this.$emit('refreshDataList')
  272. },
  273. pasteImg(e) {
  274. const { items } = e.clipboardData; // 获取粘贴板文件对象
  275. if (items.length) {
  276. for (const item of items) {
  277. if (item.type.indexOf('image') !== -1) {
  278. const file = item.getAsFile(); // 获取图片文件
  279. if (file) {
  280. uploadFile(
  281. this.$http.adornUrl('/admin/file/simpleUpload'),
  282. file
  283. ).then(({ data }) => {
  284. let obj = {url: data.resourcesUrl + data.filePath, response: {filePath: data.filePath }}
  285. this.fileList.push(obj)
  286. })
  287. }
  288. }
  289. }
  290. }
  291. },
  292. onUploadSuccess(response, file, fileList){
  293. this.fileList = fileList;
  294. },
  295. handlePicRemove(file, fileList){
  296. this.fileList = fileList;
  297. },
  298. handlePicPreview(file){
  299. this.dialogImageUrl = file.url
  300. let url = file.response.resourcesUrl + file.response.filePath
  301. this.videoFlag = this.checkMediaType(url)
  302. this.imgDialogVisible = true
  303. },
  304. querySearch (queryString, cb) {
  305. var restaurants = this.videoPlatformList
  306. var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants
  307. // 调用 callback 返回建议列表的数据
  308. cb(results)
  309. },
  310. createFilter (queryString) {
  311. return (restaurant) => {
  312. return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
  313. }
  314. },
  315. getShopList() {
  316. this.$http({
  317. url: this.$http.adornUrl('/platform/shopDetail/getShopList'),
  318. method: 'get',
  319. params: this.$http.adornParams({})
  320. }).then(({ data }) => {
  321. if (data) {
  322. this.shopList = data
  323. }
  324. })
  325. },
  326. // 表单提交
  327. dataFormSubmit () {
  328. let filePath = [];
  329. this.$refs['dataForm'].validate((valid) => {
  330. if (valid) {
  331. if(this.fileList.length > 0 && !this.dataForm.id){
  332. this.fileList.forEach(item => {
  333. filePath.push(item.response.filePath);
  334. });
  335. this.dataForm.pic = filePath.join(",");
  336. }else{
  337. this.fileList.forEach(item => {
  338. filePath.push(item.response.filePath);
  339. });
  340. this.dataForm.pic = filePath.join(",");
  341. }
  342. this.$http({
  343. url: this.$http.adornUrl('/promotion/promotionVideo'),
  344. method: this.dataForm.id ? 'put' : 'post',
  345. data: this.$http.adornData(this.dataForm)
  346. }).then(({data}) => {
  347. this.$message({
  348. message: this.$i18n.t('publics.operation'),
  349. type: 'success',
  350. })
  351. this.visible = false
  352. this.$emit('refreshDataList')
  353. })
  354. }
  355. })
  356. }
  357. }
  358. }
  359. </script>