Newer
Older
DH_Apicture / src / views / voice / voiceUnitRealtimeRecognitionRecord / index.vue
@zhangqy zhangqy 28 days ago 12 KB first commit
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="128px">
      <el-form-item label="识别动作编号" prop="recognitionActionCode">
        <el-input
          v-model="queryParams.recognitionActionCode"
          placeholder="请输入识别动作编号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="识别数据来源编号" prop="recognitionDataSourceCode">
        <el-input
          v-model="queryParams.recognitionDataSourceCode"
          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-form-item>
    </el-form>

    <!-- <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['voice:voiceUnitRealtimeRecognitionRecord:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['voice:voiceUnitRealtimeRecognitionRecord:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['voice:voiceUnitRealtimeRecognitionRecord:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['voice:voiceUnitRealtimeRecognitionRecord:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row> -->

    <el-table
      v-loading="loading"
      :data="voiceUnitRealtimeRecognitionRecordList"
      @selection-change="handleSelectionChange"
      height="70vh"
    >
      <el-table-column type="index" label="序号" width="55" align="center" />
      <el-table-column label="语音文件" align="center" prop="voiceFilePath">
        <template #default="scope">
          <audio ref="audioPlayer" controls :src="scope.row.voiceFilePath"></audio>
        </template>
      </el-table-column>
      <el-table-column label="业务来源编号" align="center" prop="businessSourceCode"> </el-table-column>
      <el-table-column label="识别结果" align="center" prop="recognitionResult" />
      <el-table-column label="识别动作编号" align="center" prop="recognitionActionCode"> </el-table-column>
      <el-table-column label="识别数据来源编号" align="center" prop="recognitionDataSourceCode"> </el-table-column>
      <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button
            link
            type="primary"
            icon="View"
            @click="handleDetail(scope.row)"
            v-hasPermi="['voice:voiceUnitRealtimeRecognitionRecord:view']"
            >详情</el-button
          >
          <el-button
            link
            type="warning"
            icon="Edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['voice:voiceUnitRealtimeRecognitionRecord:edit']"
            >修改</el-button
          >
          <el-button
            link
            type="danger"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['voice:voiceUnitRealtimeRecognitionRecord: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="500px" append-to-body>
      <el-form ref="voiceUnitRealtimeRecognitionRecordRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="语音文件路径" prop="voiceFilePath">
          <el-input v-model="form.voiceFilePath" placeholder="请输入语音文件路径" />
        </el-form-item>
        <el-form-item label="业务来源编号" prop="businessSourceCode">
          <el-input v-model="form.businessSourceCode" placeholder="请输入业务来源编号" />
        </el-form-item>
        <el-form-item label="识别结果" prop="recognitionResult">
          <el-input v-model="form.recognitionResult" placeholder="请输入识别结果" />
        </el-form-item>
        <el-form-item label="识别动作编号" prop="recognitionActionCode">
          <el-input v-model="form.recognitionActionCode" placeholder="请输入识别动作编号" />
        </el-form-item>
        <el-form-item label="识别数据来源编号" prop="recognitionDataSourceCode">
          <el-input v-model="form.recognitionDataSourceCode" placeholder="请输入识别数据来源编号" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="删除标志" prop="delFlag">
          <el-input v-model="form.delFlag" 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.voiceFilePath }}
          </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 class="flex flex-r">
          <div class="detail-label flex flex-align-center">识别结果</div>
          <div class="detail-value flex flex-align-center">
            {{ dialogFormDetail.recognitionResult }}
          </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.recognitionActionCode }}
          </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.recognitionDataSourceCode }}
          </div>
        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="cancel">关 闭</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="VoiceUnitRealtimeRecognitionRecord">
import {
  pagevoiceUnitRealtimeRecognitionRecord,
  getvoiceUnitRealtimeRecognitionRecord,
  delvoiceUnitRealtimeRecognitionRecord,
  addvoiceUnitRealtimeRecognitionRecord,
  updatevoiceUnitRealtimeRecognitionRecord,
} from '@/api/voice/voiceUnitRealtimeRecognitionRecord';
const { proxy } = getCurrentInstance();
const voiceUnitRealtimeRecognitionRecordList = 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,
    voiceFilePath: null,
    businessSourceCode: null,
    recognitionResult: null,
    recognitionActionCode: null,
    recognitionDataSourceCode: null,
    recognitionDataId: null,
    status: null,
  },
  rules: {},
  dialogFormDetail: {}, //详情弹框数据
});

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

/** 查询语音实时识别记录列表 */
function getList() {
  loading.value = true;
  pagevoiceUnitRealtimeRecognitionRecord(queryParams.value).then(response => {
    response.data.map(item => {
      item.voiceFilePath = item.voiceFilePath ? pathToUrl(item.voiceFilePath) : '';
    });

    voiceUnitRealtimeRecognitionRecordList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}

function pathToUrl(path) {
  if (path) {
    const parts = path.split('\\');
    const fileName = parts[parts.length - 1];
    if (process.env.NODE_ENV === 'development') {
      // 在开发环境中,您可能需要使用不同的逻辑来处理 URL
      return `http://192.168.20.43:9100/voice/file/${encodeURIComponent(parts[1])}/${fileName}`;
    } else {
      // 在生产环境中,使用实际的服务器地址和端口
      return `${window.location.origin}/voice-file${path}`;
    }
  } else {
    return '';
  }
}

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

// 表单重置
function reset() {
  form.value = {
    id: null,
    voiceFilePath: null,
    businessSourceCode: null,
    recognitionResult: null,
    recognitionActionCode: null,
    recognitionDataSourceCode: null,
    recognitionDataId: null,
    remark: null,
    status: null,
    delFlag: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
  };
  proxy.resetForm('voiceUnitRealtimeRecognitionRecordRef');
}

/** 搜索按钮操作 */
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;
  getvoiceUnitRealtimeRecognitionRecord(_id).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = '修改语音实时识别记录';
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs['voiceUnitRealtimeRecognitionRecordRef'].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updatevoiceUnitRealtimeRecognitionRecord(form.value).then(response => {
          proxy.$modal.msgSuccess('修改成功');
          open.value = false;
          getList();
        });
      } else {
        addvoiceUnitRealtimeRecognitionRecord(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 delvoiceUnitRealtimeRecognitionRecord(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}

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