企微助手 ,仓库名 短剧

playletManage.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div v-loading="loading" class="playletManage-wrap">
  3. <div class="screenBox flex">
  4. <div class="flex">
  5. <selfChannel title="平台" type="platform" labelWidth @channelDefine="onChangePlatform" />
  6. <div class="flex" style="margin-left: 30px;">
  7. <span style="font-size: 14px; color: #666; margin-right: 8px;">账号</span>
  8. <el-select class="select-cls" v-model="filter.account_id" size="small" placeholder="平台账号" clearable filterable :style="{width: '210px'}" @change="onChangeAccountId">
  9. <el-option v-for="item in accountOptions" :key="item.account_id" :label="item.account" :value="item.account_id" />
  10. </el-select>
  11. </div>
  12. <selfInput label_name="搜索剧集" @inputChange="onInputKeyword" />
  13. </div>
  14. <div class="right">
  15. <el-badge :value="playletList_selected.length" :hidden="playletList_selected.length < 1">
  16. <el-button type="primary" plain size="mini" @click="onClickCreatePlayletGroup">创建组</el-button>
  17. </el-badge>
  18. </div>
  19. </div>
  20. <el-table ref="tableDom" :height="height" :data="playletList" tooltip-effect="dark" style="width: 100%;margin-top:10px">
  21. <el-table-column label="剧名" prop="name" min-width="160" align="center" fixed="left" />
  22. <el-table-column label="封面" min-width="160" align="center">
  23. <template slot-scope="{ row }">
  24. <el-image style="width: 40px; height: 60px;" :src="row.cover_url" :preview-src-list="[row.cover_url]" />
  25. </template>
  26. </el-table-column>
  27. <el-table-column label="平台" prop="platform_name" min-width="160" align="center">
  28. <template slot-scope="{ row }">
  29. <span>{{ row.platform_name }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="账号" prop="account" min-width="160" align="center" />
  33. <el-table-column label="分类" prop="category" min-width="160" align="center">
  34. <template slot-scope="{ row }">
  35. <span>{{ row.category || '-' }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="集数" prop="section_count" min-width="160" align="center" />
  39. <el-table-column label="发布时间" prop="create_date" min-width="160" align="center" />
  40. <el-table-column label="状态" min-width="160" align="center">
  41. <template slot-scope="{ row }">
  42. <span v-if="row.finish_state == 1" class="status">已完结</span>
  43. <span v-else class="status">连载中</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="操作" min-width="210" align="center" fixed="right">
  47. <template slot-scope="{ row }">
  48. <span class="btn" @click="onClickCreateSend(row, { jumpPath: routePathType.GROUP_SEND })">创建群发</span>
  49. <span class="btn" @click="onClickCreateSend(row, { jumpPath: routePathType.WELCOME_MSG })">创建欢迎语</span>
  50. <template>
  51. <span v-if="handleGetIsSelected(row)" class="btn disabled">已加入</span>
  52. <span v-else class="btn" @click="onClickSelectPlaylet(row)">加入剧组</span>
  53. </template>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <div class="pagination" v-show="pagination.total > 0">
  58. <el-pagination background :current-page="pagination.page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count="Number(pagination.pages)">
  59. </el-pagination>
  60. </div>
  61. <!-- S 创建群发 -->
  62. <playletSendDialog
  63. :dialogVisible="playletSendDialogVisible"
  64. :playletInfo="currentPlayletInfo"
  65. :isCreateGroup="isCreateGroup"
  66. @confirm="handlePlayletSendConfirm"
  67. @cancel="handlePlayletSendCancel"
  68. />
  69. <!-- E 创建群发 -->
  70. <!-- S 创建组 -->
  71. <groupDialog
  72. :dialogVisible="groupDialogVisible"
  73. :selectedPlayletListFromProps="playletList_selected"
  74. @confirm="onConfirmGroupDialog"
  75. @cancel="onCancelGroupDialog"
  76. />
  77. <!-- E 创建组 -->
  78. </div>
  79. </template>
  80. <script>
  81. import selfChannel from '@/components/assembly/screen/channel.vue'
  82. import selfInput from '@/components/assembly/screen/input.vue'
  83. import playletSendDialog from './dialog/playletSendDialog.vue'
  84. import groupDialog from './dialog/groupDialog.vue'
  85. import { pageFromType, routePathType } from '@/assets/js/staticTypes'
  86. export default {
  87. name: 'playletManage',
  88. components: {
  89. selfChannel,
  90. selfInput,
  91. playletSendDialog,
  92. groupDialog,
  93. },
  94. data () {
  95. return {
  96. routePathType,
  97. height: '',
  98. loading: false,
  99. pagination: {
  100. page: 1,
  101. page_size: 20,
  102. pages: 0,
  103. total: 0,
  104. },
  105. filter: {
  106. platform_id: '',
  107. account_id: '',
  108. keyword: '',
  109. },
  110. playletList: [],
  111. accountOptions: [], // 账号选项
  112. playletSendDialogVisible: false, // 控制"添加账号"弹框显示
  113. currentPlayletInfo: {}, // 当前编辑的账号信息
  114. currentJumpRoutePath: '', // 当前路由跳转路径 创建群发 & 创建欢迎语
  115. isCreateGroup: false, // 当前操作是否为“加入剧组”
  116. playletList_selected: [], // 当前已选的短剧列表数据
  117. groupDialogVisible: false, // 控制"创建组"弹框显示
  118. }
  119. },
  120. created () {
  121. this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
  122. this.handleGetPlaylet()
  123. },
  124. methods: {
  125. // 获取列表数据
  126. async handleGetPlaylet() {
  127. try {
  128. this.loading = true
  129. const url = `${this.URL.BASEURL}${this.URL.playletManage_playletList}`
  130. const params = {
  131. platform_id: this.filter.platform_id,
  132. keyword: this.filter.keyword,
  133. account_id: this.filter.account_id,
  134. page: this.pagination.page,
  135. page_size: this.pagination.page_size,
  136. }
  137. const { data: res = {} } = await this.$axios.get(url, { params })
  138. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  139. this.playletList = res.rst.data;
  140. this.pagination.total = res.rst.pageInfo.total;
  141. this.pagination.pages = res.rst.pageInfo.pages;
  142. this.$refs.tableDom.bodyWrapper.scrollTop = 0
  143. } else if (res.errno != 4002) {
  144. this.$message.warning(res.err)
  145. this.playletList = [];
  146. this.pagination.total = 0;
  147. this.pagination.pages = 0;
  148. }
  149. } catch (error) {
  150. console.log(error)
  151. this.playletList = [];
  152. this.pagination.total = 0;
  153. this.pagination.pages = 0;
  154. } finally {
  155. this.loading = false
  156. }
  157. },
  158. // 监听当前页数变化
  159. handleCurrentChange(currentPage) {
  160. this.pagination.page = currentPage
  161. this.handleGetPlaylet()
  162. },
  163. // 监听"平台"筛选变化
  164. async onChangePlatform(val) {
  165. this.filter.platform_id = val || ''
  166. // 清空“账号”筛选值 => 根据最新平台值 获取 账号选项
  167. this.filter.account_id = ''
  168. this.accountOptions = []
  169. if (this.filter.platform_id) {
  170. this.handleGetAccountOptions()
  171. }
  172. await this.$nextTick()
  173. this.pagination.page = 1
  174. this.handleGetPlaylet()
  175. },
  176. // 监听"账号"筛选变化
  177. onChangeAccountId(val) {
  178. this.filter.account_id = val || ''
  179. this.pagination.page = 1
  180. this.handleGetPlaylet()
  181. },
  182. // 监听"搜索剧集"变化
  183. onInputKeyword(val) {
  184. this.filter.keyword = val || ''
  185. this.pagination.page = 1
  186. this.handleGetPlaylet()
  187. },
  188. // 获取账号选项列表
  189. async handleGetAccountOptions() {
  190. const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.playletManage_accountList, {
  191. platform_id: this.filter.platform_id
  192. })
  193. if (res && res.errno == 0) {
  194. this.accountOptions = res.rst
  195. } else if (res.errno != 4002) {
  196. this.$message.warning(res.err)
  197. }
  198. },
  199. // 获取当前短剧“已加入”状态
  200. handleGetIsSelected(row) {
  201. return this.playletList_selected.find(item => item.playlet_id === row.playlet_id)
  202. },
  203. // S 创建群发、"创建欢迎语"
  204. // 监听点击"创建群发"、"创建欢迎语"
  205. onClickCreateSend(playletInfo, { jumpPath }) {
  206. this.isCreateGroup = false
  207. this.currentPlayletInfo = playletInfo
  208. this.currentJumpRoutePath = jumpPath
  209. this.playletSendDialogVisible = true
  210. },
  211. // 监听点击“加入剧组”
  212. onClickSelectPlaylet(playletInfo) {
  213. this.isCreateGroup = true
  214. this.currentPlayletInfo = playletInfo
  215. this.currentJumpRoutePath = ''
  216. this.playletSendDialogVisible = true
  217. },
  218. // 创建群发 => 确定
  219. handlePlayletSendConfirm({ miniProPath, miniProAppId, miniProDesc, miniProCover, h5Path, h5Desc, h5Cover, link_type }) {
  220. console.log('handlePlayletSendConfirm => ')
  221. this.playletSendDialogVisible = false
  222. this.handleGetPlaylet()
  223. if (this.currentJumpRoutePath) { // 有跳转路径 => 跳转"客户群发"&&新建群发 || "创建欢迎语"&&新建欢迎语
  224. if (link_type === 1) { // H5推广链接
  225. const path = this.$router.resolve({
  226. path: this.currentJumpRoutePath,
  227. query: {
  228. from: pageFromType.PLAYLET_LINK_H5,
  229. h5Path: encodeURIComponent(h5Path),
  230. h5Desc: encodeURIComponent(h5Desc),
  231. h5Cover: encodeURIComponent(h5Cover),
  232. }
  233. })
  234. window.open(path.href, '_blank')
  235. } else if (link_type === 0) { // 小程序链接
  236. const path = this.$router.resolve({
  237. path: this.currentJumpRoutePath,
  238. query: {
  239. from: pageFromType.PLAYLET_LINK_MINIAPP,
  240. miniProPath: encodeURIComponent(miniProPath),
  241. miniProAppId: encodeURIComponent(miniProAppId),
  242. miniProDesc: encodeURIComponent(miniProDesc),
  243. miniProCover: encodeURIComponent(miniProCover),
  244. }
  245. })
  246. window.open(path.href, '_blank')
  247. }
  248. } else { // 没有跳转路径 => 加入剧组
  249. this.playletList_selected.push({
  250. ...this.currentPlayletInfo,
  251. miniProPath,
  252. miniProAppId,
  253. miniProDesc,
  254. miniProCover,
  255. h5Path,
  256. h5Desc,
  257. h5Cover,
  258. link_type,
  259. })
  260. }
  261. },
  262. // 创建群发 => 取消
  263. handlePlayletSendCancel() {
  264. this.playletSendDialogVisible = false
  265. },
  266. // E 创建群发
  267. // 监听点击“创建组”
  268. onClickCreatePlayletGroup() {
  269. this.groupDialogVisible = true
  270. },
  271. onConfirmGroupDialog() {
  272. this.groupDialogVisible = false
  273. },
  274. onCancelGroupDialog() {
  275. this.groupDialogVisible = false
  276. },
  277. }
  278. }
  279. </script>
  280. <style lang="scss" scoped>
  281. .screenBox {
  282. background: #fff;
  283. padding: 5px 20px;
  284. .right {
  285. padding-right: 14px;
  286. }
  287. }
  288. /deep/ .el-select .el-input.is-focus .el-input__inner,
  289. /deep/ .el-select .el-input__inner:focus {
  290. border-color: #DCDFE6;
  291. }
  292. .playletManage-wrap {
  293. .select-cls {
  294. /deep/ .el-input__suffix {
  295. border-top-right-radius: 4px;
  296. border-bottom-right-radius: 4px;
  297. border: 1px solid #DCDFE6;
  298. right: 0;
  299. width: 30px;
  300. background-color: #F1F1F1;
  301. .el-input__icon {
  302. color: #909399;
  303. }
  304. }
  305. }
  306. .playlet-name {
  307. color: #32B38A;
  308. // cursor: pointer;
  309. }
  310. .status {
  311. margin: 2px auto;
  312. padding: 0 6px;
  313. color: #32B38A;
  314. border: 1px solid #32B38A;
  315. }
  316. .btn {
  317. color: #32B38A;
  318. cursor: pointer;
  319. margin-right: 4px;
  320. &.disabled {
  321. color: #999;
  322. cursor: not-allowed;
  323. }
  324. &:last-child {
  325. margin-right: 0;
  326. }
  327. }
  328. }
  329. </style>