index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
  4. <el-form-item label="类型" prop="voiceType">
  5. <el-select v-model="queryParams.voiceType" placeholder="请选择">
  6. <el-option v-for="item in dict.type.voice_type" :key="item.value" :label="item.label"
  7. :value="item.value">
  8. </el-option>
  9. </el-select>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  13. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  14. </el-form-item>
  15. </el-form>
  16. <el-row :gutter="10" class="mb8">
  17. <el-col :span="1.5">
  18. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
  19. </el-col>
  20. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  21. </el-row>
  22. <el-table v-loading="loading" :data="listData" row-key="id">
  23. <el-table-column prop="voiceName" label="音效名称" > </el-table-column>
  24. <el-table-column prop="voiceUrl" label="音效地址" width="350px">
  25. <template slot-scope="scope">
  26. <audio :src="scope.row.voiceUrl" controls></audio>
  27. </template>
  28. </el-table-column>
  29. <el-table-column prop="voiceType" label="音效类型">
  30. <template slot-scope="scope">
  31. <dict-tag :options="dict.type.voice_type" :value="scope.row.voiceType" />
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="orgName" label="机构名称"> </el-table-column>
  35. <!-- <el-table-column prop="status" label="状态">
  36. <template slot-scope="scope">
  37. <dict-tag :options="dict.type.dict_status" :value="scope.row.status" />
  38. </template>
  39. </el-table-column> -->
  40. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  41. <template slot-scope="scope">
  42. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
  43. <el-button size="mini" type="text" style="color: red;" @click="handelDel(scope.row.id)">删除</el-button>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <!-- 添加或修改机构对话框 -->
  48. <el-dialog :beforeClose="cancel" :title="title" :visible.sync="open" width="500px" append-to-body destroy-on-close>
  49. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  50. <el-form-item label="音效名称" prop="voiceName">
  51. <el-input v-model.trim="form.voiceName" placeholder="请输入音效名称" maxlength="20" />
  52. </el-form-item>
  53. <el-form-item label="音效类型" prop="voiceType">
  54. <el-select v-model="form.voiceType" placeholder="请选择" style="width: 100%;">
  55. <el-option v-for="item in dict.type.voice_type" :key="item.value" :label="item.label" :value="item.value">
  56. </el-option>
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item prop="voiceUrl" label="游戏音效">
  60. <FileUpload ref="videoUpload" :fileSize="50" :fileType="['mp3', 'wav']" v-if="open" :isShowTip="false"
  61. :paramsData="{ dirName: 'gameVideo' }" />
  62. </el-form-item>
  63. <el-form-item label="备注" prop="remark">
  64. <el-input v-model.trim="form.remark" placeholder="请输入备注" type="textarea" maxlength="50" />
  65. </el-form-item>
  66. </el-form>
  67. <div slot="footer" class="dialog-footer">
  68. <el-button type="primary" @click="submitForm">确 定</el-button>
  69. <el-button @click="cancel">取 消</el-button>
  70. </div>
  71. </el-dialog>
  72. </div>
  73. </template>
  74. <script>
  75. import { listData, gameVoiceSave,delById,gameVoiceEdit } from "@/api/system/gameVideo";
  76. export default {
  77. name: "gameVideo_list",
  78. dicts: ['voice_type'],
  79. components: {},
  80. data() {
  81. return {
  82. // 遮罩层
  83. loading: true,
  84. // 显示搜索条件
  85. showSearch: true,
  86. // 表格树数据
  87. listData: [],
  88. // 弹出层标题
  89. title: "",
  90. // 是否显示弹出层
  91. open: false,
  92. // 查询参数
  93. queryParams: {
  94. page: 1,
  95. limit: 10,
  96. voiceType:undefined
  97. },
  98. // 表单参数
  99. form: {
  100. },
  101. // 表单校验
  102. rules: {
  103. voiceName: [{ required: true, message: "音效名称不能为空" }],
  104. voiceType: [{ required: true, message: "音效类型不能为空" }],
  105. }
  106. };
  107. },
  108. created() {
  109. this.getList();
  110. },
  111. methods: {
  112. /** 查询列表 */
  113. getList() {
  114. this.loading = true;
  115. listData(this.queryParams).then(response => {
  116. this.listData = response.data
  117. this.loading = false;
  118. });
  119. },
  120. // 取消按钮
  121. cancel() {
  122. this.open = false;
  123. this.$refs["form"].resetFields()
  124. this.reset();
  125. },
  126. // 表单重置
  127. reset() {
  128. this.form = {
  129. };
  130. },
  131. /** 搜索按钮操作 */
  132. handleQuery() {
  133. this.getList();
  134. },
  135. /** 重置按钮操作 */
  136. resetQuery() {
  137. this.resetForm("queryForm");
  138. this.handleQuery();
  139. },
  140. /** 新增按钮操作 */
  141. handleAdd(row) {
  142. this.reset();
  143. this.open = true;
  144. this.title = "添加";
  145. },
  146. /** 修改按钮操作 */
  147. handleUpdate(row) {
  148. let catchForm = JSON.parse(JSON.stringify(row))
  149. this.form = catchForm
  150. this.open = true;
  151. this.title = "修改";
  152. },
  153. /** 删除按钮 */
  154. handelDel(id) {
  155. this.$confirm('此操作将永久删除, 是否继续?', '提示', {
  156. confirmButtonText: '确定',
  157. cancelButtonText: '取消',
  158. type: 'warning'
  159. }).then(() => {
  160. delById({ id }).then(res => {
  161. this.$modal.msgSuccess(`删除成功`);
  162. this.getList()
  163. })
  164. }).catch(() => {
  165. });
  166. },
  167. /** 提交按钮 */
  168. submitForm() {
  169. this.$refs["form"].validate(valid => {
  170. if (valid) {
  171. let catchForm = this.form
  172. catchForm.voiceUrl = this.$refs.videoUpload.fileList.length != 0 ? this.$refs.videoUpload.fileList[0].name : catchForm.voiceUrl
  173. if (!catchForm.voiceUrl) {
  174. this.$modal.msgError('请上传音效');
  175. return
  176. }
  177. if(catchForm.id === null || catchForm.id === undefined || catchForm.id ===""){
  178. gameVoiceSave(catchForm).then(res => {
  179. this.$modal.msgSuccess(catchForm.id ? '修改成功' : '添加成功');
  180. this.open = false
  181. this.getList()
  182. })
  183. }else {
  184. gameVoiceEdit(catchForm).then(res => {
  185. this.$modal.msgSuccess(catchForm.id ? '修改成功' : '添加成功');
  186. this.open = false
  187. this.getList()
  188. })
  189. }
  190. }
  191. });
  192. },
  193. }
  194. };
  195. </script>