| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <template>
- <div class="app-container">
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
- <el-form-item label="类型" prop="voiceType">
- <el-select v-model="queryParams.voiceType" placeholder="请选择">
- <el-option v-for="item in dict.type.voice_type" :key="item.value" :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
- </el-col>
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
- </el-row>
- <el-table v-loading="loading" :data="listData" row-key="id">
-
- <el-table-column prop="voiceName" label="音效名称" > </el-table-column>
- <el-table-column prop="voiceUrl" label="音效地址" width="350px">
- <template slot-scope="scope">
- <audio :src="scope.row.voiceUrl" controls></audio>
- </template>
- </el-table-column>
- <el-table-column prop="voiceType" label="音效类型">
- <template slot-scope="scope">
- <dict-tag :options="dict.type.voice_type" :value="scope.row.voiceType" />
- </template>
- </el-table-column>
- <el-table-column prop="orgName" label="机构名称"> </el-table-column>
- <!-- <el-table-column prop="status" label="状态">
- <template slot-scope="scope">
- <dict-tag :options="dict.type.dict_status" :value="scope.row.status" />
- </template>
- </el-table-column> -->
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
- <el-button size="mini" type="text" style="color: red;" @click="handelDel(scope.row.id)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <!-- 添加或修改机构对话框 -->
- <el-dialog :beforeClose="cancel" :title="title" :visible.sync="open" width="500px" append-to-body destroy-on-close>
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
- <el-form-item label="音效名称" prop="voiceName">
- <el-input v-model.trim="form.voiceName" placeholder="请输入音效名称" maxlength="20" />
- </el-form-item>
- <el-form-item label="音效类型" prop="voiceType">
- <el-select v-model="form.voiceType" placeholder="请选择" style="width: 100%;">
- <el-option v-for="item in dict.type.voice_type" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item prop="voiceUrl" label="游戏音效">
- <FileUpload ref="videoUpload" :fileSize="50" :fileType="['mp3', 'wav']" v-if="open" :isShowTip="false"
- :paramsData="{ dirName: 'gameVideo' }" />
- </el-form-item>
- <el-form-item label="备注" prop="remark">
- <el-input v-model.trim="form.remark" placeholder="请输入备注" type="textarea" maxlength="50" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitForm">确 定</el-button>
- <el-button @click="cancel">取 消</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { listData, gameVoiceSave,delById,gameVoiceEdit } from "@/api/system/gameVideo";
- export default {
- name: "gameVideo_list",
- dicts: ['voice_type'],
- components: {},
- data() {
- return {
- // 遮罩层
- loading: true,
- // 显示搜索条件
- showSearch: true,
- // 表格树数据
- listData: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- // 查询参数
- queryParams: {
- page: 1,
- limit: 10,
- voiceType:undefined
- },
- // 表单参数
- form: {
- },
- // 表单校验
- rules: {
- voiceName: [{ required: true, message: "音效名称不能为空" }],
- voiceType: [{ required: true, message: "音效类型不能为空" }],
- }
- };
- },
- created() {
- this.getList();
- },
- methods: {
- /** 查询列表 */
- getList() {
- this.loading = true;
- listData(this.queryParams).then(response => {
- this.listData = response.data
- this.loading = false;
- });
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.$refs["form"].resetFields()
- this.reset();
- },
- // 表单重置
- reset() {
- this.form = {
- };
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm("queryForm");
- this.handleQuery();
- },
- /** 新增按钮操作 */
- handleAdd(row) {
- this.reset();
- this.open = true;
- this.title = "添加";
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- let catchForm = JSON.parse(JSON.stringify(row))
- this.form = catchForm
- this.open = true;
- this.title = "修改";
- },
- /** 删除按钮 */
- handelDel(id) {
- this.$confirm('此操作将永久删除, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- delById({ id }).then(res => {
- this.$modal.msgSuccess(`删除成功`);
- this.getList()
- })
- }).catch(() => {
- });
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate(valid => {
- if (valid) {
- let catchForm = this.form
- catchForm.voiceUrl = this.$refs.videoUpload.fileList.length != 0 ? this.$refs.videoUpload.fileList[0].name : catchForm.voiceUrl
- if (!catchForm.voiceUrl) {
- this.$modal.msgError('请上传音效');
- return
- }
- if(catchForm.id === null || catchForm.id === undefined || catchForm.id ===""){
- gameVoiceSave(catchForm).then(res => {
- this.$modal.msgSuccess(catchForm.id ? '修改成功' : '添加成功');
- this.open = false
- this.getList()
- })
- }else {
- gameVoiceEdit(catchForm).then(res => {
- this.$modal.msgSuccess(catchForm.id ? '修改成功' : '添加成功');
- this.open = false
- this.getList()
- })
- }
-
- }
- });
- },
- }
- };
- </script>
|