123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <template>
- <div class="app-container">
- <el-form ref="queryForm" :model="queryParams" :inline="true" @submit.native.prevent>
- <el-form-item label="文本" prop="text">
- <el-input v-model="queryParams.text" placeholder="请输入关键词搜索" clearable size="small" @keyup.enter.native="handleQuery" />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
- <el-button type="primary" plain icon="el-icon-delete" size="mini" @click="handleExport">导出</el-button>
- <el-table :data="dataList" style="width: 100%" row-key="id" @selection-change="handleSelectionChange">
- <el-table-column type="selection" width="55" />
- <el-table-column prop="number" align="center" label="序号" width="55" />
- <el-table-column prop="text" align="center" label="文本" />
- <!-- <el-table-column prop="is_mark" align="center" label="是否标注" width="120">
- <template slot-scope="scope">
- <el-switch v-model="scope.row.is_mark" active-color="#13ce66" :active-value="1" :inactive-value="0" />
- </template>
- </el-table-column> -->
- <el-table-column prop="state" align="center" label="标注状态" width="120">
- <template slot-scope="scope">
- <el-tag size="mini" :type="scope.row.state?'success':'danger'">{{ scope.row.state?'已标注':'未标注' }}</el-tag>
- </template>
- </el-table-column>
- <el-table-column prop="examine" align="center" label="审核状态" width="120">
- <template slot-scope="scope">
- <el-tag size="mini" :type="scope.row.examine?'success':'warning'">{{ scope.row.examine?'已审核':'未审核' }}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="200">
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="handleCheck(scope.row)">查看</el-button>
- <el-button type="text" size="small" @click="beginMark(scope.row)">标注</el-button>
- <el-button size="mini" type="text" @click="handleUpdate(scope.row)">编辑</el-button>
- <el-button size="mini" type="text" @click="handleDelete(scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.size" @pagination="getList" />
- <el-dialog :title="title" :visible.sync="dialogVisible" width="40%" append-to-body :close-on-click-modal="false">
- <el-form ref="form" label-width="80px" :model="form" :rules="rules" @submit.native.prevent>
- <el-form-item label="文本" prop="text">
- <el-input v-model="form.text" type="textarea" placeholder="请输入" @keyup.enter.native="submitForm" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- <el-button type="primary" @click="submitForm">{{ form.id ? '确认修改' : '确认添加' }}</el-button>
- </div>
- </el-dialog>
- <el-dialog :title="title" :visible.sync="checkDialog" width="70%" append-to-body :close-on-click-modal="false">
- <checkMarkData :mark-data="markDataDetail" :handle-change="handleChange" :tag-label="tagLabelList" />
- <div slot="footer" class="dialog-footer">
- <!-- <el-button @click="dialogVisible = false">删除文本</el-button> -->
- <el-button @click="dialogVisible = false">作 废</el-button>
- <el-button type="primary" @click="dialogVisible = false">通 过</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getDataListApi, updataDataApi, delDataApi, PNDataApi, exportDatasetApi } from '@/api/dataMark/dataManage'
- import { getEntityListApi } from '@/api/dataMark/entity'
- import checkMarkData from './checkMarkData.vue'
- // import { getUserInfo } from '@/api/admin'
- export default {
- name: 'DatasetDetail',
- components: { checkMarkData },
- data() {
- return {
- queryParams: {
- page: 1,
- size: 10,
- dataset_id: null,
- id: null,
- text: null,
- is_mark: null,
- state: null,
- examine: null
- },
- dialogVisible: false,
- checkDialog: false,
- // 总条数
- total: 0,
- // 弹出层标题
- title: '',
- // 表格List
- dataList: [],
- // 表单参数
- form: {},
- rules: {},
- // 多选的ID
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 多选的序号
- numbers: [],
- userInfo: {},
- // 查看标注的文本
- markDataDetail: {},
- tagLabelList: []
- }
- },
- created() {
- this.queryParams.dataset_id = this.$route.params.id
- this.getList()
- this.getLabelList()
- },
- methods: {
- getList() {
- this.loading = true
- getDataListApi(this.queryParams).then((response) => {
- this.dataList = response.data.map((item, index) => ({
- ...item,
- number: index + 1
- }))
- console.log('this.dataList', this.dataList)
- this.total = response.total
- this.loading = false
- })
- },
- // 获取实体类和关系
- getLabelList() {
- const data = {}
- getEntityListApi(data).then((res) => {
- this.tagLabelList = res.data
- })
- },
- // 表单重置
- reset() {
- this.form = {
- id: undefined,
- text: undefined,
- is_mark: undefined,
- state: undefined,
- examine: undefined
- }
- this.resetForm('form')
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs['form'].validate((valid) => {
- if (valid && this.form.id !== undefined && this.form.state === 0) {
- updataDataApi(this.form).then((response) => {
- this.$modal.msgSuccess('修改成功')
- this.dialogVisible = false
- this.getList()
- })
- } else {
- this.$modal.msgSuccess('已标注过的文本不能被修改')
- }
- })
- },
- // 删除数据集
- handleDelete(row) {
- let dataIds = []
- row.id ? (dataIds = [row.id]) : (dataIds = this.ids)
- const numbers = row.number || this.numbers
- this.$confirm('此操作将永久删除序号为' + numbers + '的数据, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(async() => {
- await delDataApi(dataIds)
- this.$message({
- message: '删除成功!',
- type: 'success'
- })
- this.getList()
- })
- },
- // 查看标注详情
- handleCheck(row) {
- this.markDataDetail = { ...row }
- this.checkDialog = true
- this.title = '详情'
- },
- // 标注按钮
- beginMark(row) {
- this.$router.push({ name: 'markPage', params: { dataset_id: row.dataset_id, id: row.id }})
- },
- // 上一条、下一条
- handleChange(id, dataset_id, type) {
- const data = { id, dataset_id, type }
- PNDataApi(data).then((response) => {
- if (response.code === 2) {
- this.$message({
- message: response.msg,
- type: 'warning'
- })
- } else {
- this.$nextTick(() => {
- this.markDataDetail = response.data[0]
- })
- }
- })
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.form = { ...row }
- this.dialogVisible = true
- this.title = '修改文本内容'
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.ids = selection.map((item) => item.id)
- this.numbers = selection.map((item) => item.number)
- console.log('numbers', this.numbers)
- this.single = selection.length !== 1
- this.multiple = !selection.length
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1
- this.getList()
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm('queryForm')
- this.handleQuery()
- },
- // 导出
- async handleExport() {
- try {
- this.addLoading = true
- const res = await exportDatasetApi(this.queryParams)
- this.addLoading = false
- this.$downFile(res)
- } catch (e) {
- this.addLoading = false
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped></style>
|