Newer
Older
urbanLifeline_YanAn / src / views / voice / voiceUnitHotWords / index.vue
@zhangqy zhangqy on 3 Oct 9 KB first commit
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item v-show="false" label="业务来源编号" prop="businessSourceCode">
        <el-input
          v-model="queryParams.businessSourceCode"
          placeholder="请输入业务来源编号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="热词名称" prop="hotWordName">
        <el-input v-model="queryParams.hotWordName" placeholder="请输入热词名称" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        <el-col :span="1.5">
          <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['voice:voiceUnitHotWords:add']"
            >新增</el-button
          >
        </el-col>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="voiceUnitHotWordsList" @selection-change="handleSelectionChange" height="70vh">
      <el-table-column type="index" label="序号" width="55" align="center" />
      <el-table-column label="热词名称" align="center" prop="hotWordName" />
      <el-table-column label="热词拼音" align="center" prop="hotWordPinying" />
      <el-table-column label="热词类型" align="center" prop="hotWordType">
        <template #default="scope">
          <dict-tag :options="sys_hotwordtype" :value="scope.row.hotWordType" />
        </template>
      </el-table-column>
      <el-table-column label="业务来源编号" align="center" prop="businessSourceCode"> </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
        <template #default="scope">
          <el-button
            link
            type="primary"
            icon="View"
            @click="handleDetail(scope.row)"
            v-hasPermi="['voice:voiceUnitHotWords:view']"
            >详情</el-button
          >
          <el-button
            link
            type="warning"
            icon="Edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['voice:voiceUnitHotWords:edit']"
            >修改</el-button
          >
          <el-button
            link
            type="danger"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['voice:voiceUnitHotWords:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改语音热词管理对话框 -->
    <el-dialog :title="title" v-model="open" width="600px" append-to-body>
      <el-form ref="voiceUnitHotWordsRef" :model="form" :rules="rules" label-width="150px">
        <el-form-item label="热词名称" prop="hotWordName">
          <el-input v-model="form.hotWordName" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="热词类型" prop="hotWordType">
          <el-select v-model="form.hotWordType" placeholder="请选择热词类型" style="width: 100%">
            <el-option v-for="dict in sys_hotwordtype" :key="dict.value" :label="dict.label" :value="dict.value"> </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="业务来源编号" prop="businessSourceCode">
          <el-input v-model="form.businessSourceCode" placeholder="请输入业务来源编号" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 语音热词管理详情 -->
    <el-dialog title="语音热词管理详情" v-model="detailOpen" width="800px" append-to-body class="dialog-detail-box">
      <div class="dialog-form-detail flex flex-r flex-wrap">
        <div class="flex flex-r">
          <div class="detail-label flex flex-align-center">热词名称</div>
          <div class="detail-value flex flex-align-center">
            {{ dialogFormDetail.hotWordName }}
          </div>
        </div>
        <div class="flex flex-r">
          <div class="detail-label flex flex-align-center">热词拼音</div>
          <div class="detail-value flex flex-align-center">
            {{ dialogFormDetail.hotWordPinying }}
          </div>
        </div>
        <div class="flex flex-r">
          <div class="detail-label flex flex-align-center">热词类型</div>
          <div class="detail-value flex flex-align-center">
            <dict-tag :options="sys_hotwordtype" :value="dialogFormDetail.hotWordType" />
          </div>
        </div>
        <div class="flex flex-r">
          <div class="detail-label flex flex-align-center">业务来源编号</div>
          <div class="detail-value flex flex-align-center">
            {{ dialogFormDetail.businessSourceCode }}
          </div>
        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="cancel">关 闭</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="VoiceUnitHotWords">
import {
  pagevoiceUnitHotWords,
  getvoiceUnitHotWords,
  delvoiceUnitHotWords,
  addvoiceUnitHotWords,
  updatevoiceUnitHotWords,
} from '@/api/voice/voiceUnitHotWords';
import useUserStore from '@/store/modules/user';
const userStore = useUserStore();

const { proxy } = getCurrentInstance();
const { sys_hotwordtype } = proxy.useDict('sys_hotwordtype');

const voiceUnitHotWordsList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref('');
const detailOpen = ref(false);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    hotWordName: null,
    hotWordPinying: null,
    hotWordType: null,
    businessSourceCode: null,
    businessDataId: null,
    status: null,
    hotWordName: null,
  },
  rules: {
    hotWordName: [{ required: true, message: '热词名称不能为空', trigger: 'blur' }],
  },
  dialogFormDetail: {}, //详情弹框数据
});

const { queryParams, form, rules, dialogFormDetail } = toRefs(data);

/** 查询语音热词管理列表 */
function getList() {
  loading.value = true;
  pagevoiceUnitHotWords(queryParams.value).then(response => {
    voiceUnitHotWordsList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  detailOpen.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    hotWordName: null,
    hotWordPinying: null,
    hotWordType: null,
    businessSourceCode: null,
    businessDataId: null,
    remark: null,
    status: null,
    delFlag: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
  };
  proxy.resetForm('voiceUnitHotWordsRef');
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = '添加语音热词管理';
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _id = row.id || ids.value;
  getvoiceUnitHotWords(_id).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = '修改语音热词管理';
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs['voiceUnitHotWordsRef'].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updatevoiceUnitHotWords(form.value).then(response => {
          proxy.$modal.msgSuccess('修改成功');
          open.value = false;
          getList();
        });
      } else {
        form.value.createBy = userStore.userInfo.userName;
        addvoiceUnitHotWords(form.value).then(response => {
          proxy.$modal.msgSuccess('新增成功');
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value;
  proxy.$modal
    .confirm('是否确认删除语音热词管理编号为"' + _ids + '"的数据项?')
    .then(function () {
      return delvoiceUnitHotWords(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    'voice/voiceUnitHotWords/export',
    {
      ...queryParams.value,
    },
    `voiceUnitHotWords_${new Date().getTime()}.xlsx`
  );
}
//查看详情操作
function handleDetail(row) {
  detailOpen.value = true;
  dialogFormDetail.value = row;
}
getList();
</script>