voiceTemplate.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="mod-prod-prodTemplate">
  3. <!-- 搜索相关区域 -->
  4. <div class="search-bar">
  5. <el-form :inline="true" class="search-form" ref="searchForm" :model="searchForm" label-width="auto" size="small">
  6. <!-- 表单项 -->
  7. <div class="input-row">
  8. <el-form-item prop="templateSeriesId" label="模板系列:">
  9. <el-select v-model="searchForm.templateSeriesId" clearable filterable>
  10. <el-option
  11. v-for="node in seriesList"
  12. :key="node.seriesId"
  13. :label="node.seriesName"
  14. :value="node.seriesId"
  15. ></el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item>
  19. <div class="default-btn primary-btn" @click="searchChange()">{{ $t('crud.searchBtn') }}</div>
  20. <div class="default-btn" @click="resetForm()">{{ $t('shop.resetMap') }}</div>
  21. </el-form-item>
  22. </div>
  23. </el-form>
  24. </div>
  25. <!-- 列表相关区域 -->
  26. <div class="main-container">
  27. <div class="operation-bar">
  28. <div class="default-btn primary-btn" @click="addOrUpdateHandle()"
  29. >{{$t("crud.addTitle")}}</div>
  30. </div>
  31. <div class="table-con spec-table">
  32. <el-table
  33. ref="specListTable"
  34. :data="dataList"
  35. header-cell-class-name="table-header"
  36. row-class-name="table-row"
  37. style="width: 100%">
  38. <el-table-column
  39. align="center"
  40. prop="templateUrl"
  41. label="语音地址"
  42. width="300">
  43. <template slot-scope="scope">
  44. <video
  45. :src="resourcesUrl + scope.row.templateUrl"
  46. v-if="scope.row.templateUrl"
  47. controls="controls"
  48. style="width:260px;height:87.5px;"
  49. />
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="模版系列" prop="templateSeries" align="center">
  53. <template slot-scope="scope">
  54. <span>{{ scope.row.templateSeries}}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column :label="$t('prodTemplate.status')" prop="status" align="center">
  58. <template slot-scope="scope">
  59. <el-tag type="success" v-if="scope.row.status === 1">启用</el-tag>
  60. <el-tag type="danger" v-if="scope.row.status === -1">禁用</el-tag>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="排序" prop="seq" align="center">
  64. <template slot-scope="scope">
  65. <span>{{ scope.row.seq}}</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column align="center" fixed="right" :label="$t('publics.operating')" width="auto">
  69. <template slot-scope="scope">
  70. <div class="text-btn-con">
  71. <div class="default-btn text-btn" @click="addOrUpdateHandle(scope.row.templateId)"
  72. >{{$t("crud.updateBtn")}}</div>
  73. <div class="default-btn text-btn" @click.stop="deleteHandle(scope.row.templateId)"
  74. >{{$t("text.delBtn")}}</div>
  75. </div>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. </div>
  80. <el-pagination
  81. v-if="dataList.length"
  82. @size-change="handleSizeChange"
  83. @current-change="handleCurrentChange"
  84. :current-page="page.currentPage"
  85. :page-sizes="[10, 20, 50, 100]"
  86. :page-size="page.pageSize"
  87. layout="total, sizes, prev, pager, next, jumper"
  88. :total="page.total">
  89. </el-pagination>
  90. </div>
  91. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="refreshChange"></add-or-update>
  92. <el-dialog :visible.sync="previewPicDialogVisible" :modal="false" title="图片预览" width="30%" top="3vh">
  93. <el-image :src="previewPicUrl" alt="" style="width: 100%; height: 100%"/>
  94. </el-dialog>
  95. </div>
  96. </template>
  97. <script>
  98. import AddOrUpdate from './voiceTemplate-add-or-update'
  99. export default {
  100. data () {
  101. return {
  102. dataList: [],
  103. page: {
  104. total: 0, // 总页数
  105. currentPage: 1, // 当前页数
  106. pageSize: 10 // 每页显示多少条
  107. },
  108. searchForm: {
  109. templateSeriesId: null,
  110. }, // 搜索
  111. dataListLoading: false,
  112. addOrUpdateVisible: false,
  113. seriesList: [],
  114. resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
  115. previewPicUrl: null,
  116. previewPicDialogVisible: false,
  117. }
  118. },
  119. components: {
  120. AddOrUpdate
  121. },
  122. created () {
  123. this.getDataList()
  124. this.getSeriesList()
  125. },
  126. mounted () {
  127. },
  128. methods: {
  129. previewPic(row){
  130. this.previewPicUrl = this.resourcesUrl + row.templateUrl
  131. this.previewPicDialogVisible = true;
  132. },
  133. getSeriesList () {
  134. this.$http({
  135. url: this.$http.adornUrl('/prod/prodTemplateSeries/page'),
  136. method: 'get',
  137. params: this.$http.adornParams(
  138. Object.assign({
  139. size: 100,
  140. shopId: this.$store.state.user.shopId
  141. },
  142. )
  143. )
  144. }).then(({data}) => {
  145. this.seriesList = data.records
  146. })
  147. },
  148. getDataList (page) {
  149. this.dataListLoading = true
  150. this.$http({
  151. url: this.$http.adornUrl('/prod/voiceTemplate/page'),
  152. method: 'get',
  153. params: this.$http.adornParams(
  154. Object.assign({
  155. current: page == null ? this.page.currentPage : page.currentPage,
  156. size: page == null ? this.page.pageSize : page.pageSize,
  157. shopId: this.$store.state.user.shopId,
  158. },
  159. this.searchForm
  160. )
  161. )
  162. }).then(({data}) => {
  163. this.dataList = data.records
  164. this.page.total = data.total
  165. this.dataListLoading = false
  166. })
  167. },
  168. // 新增 / 修改
  169. addOrUpdateHandle (id) {
  170. this.addOrUpdateVisible = true
  171. this.$nextTick(() => {
  172. this.$refs.addOrUpdate.init(id)
  173. })
  174. },
  175. deleteHandle (id) {
  176. this.$confirm(this.$i18n.t('admin.isDeleOper') + '?', this.$i18n.t('text.tips'), {
  177. confirmButtonText: this.$i18n.t('crud.filter.submitBtn'),
  178. cancelButtonText: this.$i18n.t('crud.filter.cancelBtn'),
  179. type: 'warning'
  180. }).then(() => {
  181. this.$http({
  182. url: this.$http.adornUrl('/prod/voiceTemplate/' + id),
  183. method: 'delete',
  184. data: this.$http.adornData({})
  185. }).then(({ data }) => {
  186. this.$message({
  187. message: this.$i18n.t('publics.operation'),
  188. type: 'success',
  189. duration: 100,
  190. onClose: () => {
  191. this.refreshChange()
  192. }
  193. })
  194. })
  195. }).catch(() => { })
  196. },
  197. resetForm () {
  198. this.searchForm = {
  199. templateSeriesId: null
  200. }
  201. },
  202. // 刷新回调
  203. refreshChange () {
  204. this.getDataList(this.page)
  205. },
  206. searchChange () {
  207. // this.searchForm = params
  208. this.getDataList(this.page)
  209. },
  210. handleSizeChange (val) {
  211. this.page.pageSize = val
  212. this.getDataList()
  213. },
  214. handleCurrentChange (val) {
  215. this.page.currentPage = val
  216. this.getDataList()
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss">
  222. .mod-prod-prodTemplate {
  223. }
  224. </style>