datasetDetail.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="queryForm" :model="queryParams" :inline="true" @submit.native.prevent>
  4. <el-form-item label="文本" prop="text">
  5. <el-input v-model="queryParams.text" placeholder="请输入关键词搜索" clearable size="small" @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
  9. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  10. </el-form-item>
  11. </el-form>
  12. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
  13. <el-button type="primary" plain icon="el-icon-delete" size="mini" @click="handleExport">导出</el-button>
  14. <el-table :data="dataList" style="width: 100%" row-key="id" @selection-change="handleSelectionChange">
  15. <el-table-column type="selection" width="55" />
  16. <el-table-column prop="number" align="center" label="序号" width="55" />
  17. <el-table-column prop="text" align="center" label="文本" />
  18. <!-- <el-table-column prop="is_mark" align="center" label="是否标注" width="120">
  19. <template slot-scope="scope">
  20. <el-switch v-model="scope.row.is_mark" active-color="#13ce66" :active-value="1" :inactive-value="0" />
  21. </template>
  22. </el-table-column> -->
  23. <el-table-column prop="state" align="center" label="标注状态" width="120">
  24. <template slot-scope="scope">
  25. <el-tag size="mini" :type="scope.row.state?'success':'danger'">{{ scope.row.state?'已标注':'未标注' }}</el-tag>
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="examine" align="center" label="审核状态" width="120">
  29. <template slot-scope="scope">
  30. <el-tag size="mini" :type="scope.row.examine?'success':'warning'">{{ scope.row.examine?'已审核':'未审核' }}</el-tag>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="操作" align="center" width="200">
  34. <template slot-scope="scope">
  35. <el-button type="text" size="small" @click="handleCheck(scope.row)">查看</el-button>
  36. <el-button type="text" size="small" @click="beginMark(scope.row)">标注</el-button>
  37. <el-button size="mini" type="text" @click="handleUpdate(scope.row)">编辑</el-button>
  38. <el-button size="mini" type="text" @click="handleDelete(scope.row)">删除</el-button>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.size" @pagination="getList" />
  43. <el-dialog :title="title" :visible.sync="dialogVisible" width="40%" append-to-body :close-on-click-modal="false">
  44. <el-form ref="form" label-width="80px" :model="form" :rules="rules" @submit.native.prevent>
  45. <el-form-item label="文本" prop="text">
  46. <el-input v-model="form.text" type="textarea" placeholder="请输入" @keyup.enter.native="submitForm" />
  47. </el-form-item>
  48. </el-form>
  49. <div slot="footer" class="dialog-footer">
  50. <el-button @click="dialogVisible = false">取 消</el-button>
  51. <el-button type="primary" @click="submitForm">{{ form.id ? '确认修改' : '确认添加' }}</el-button>
  52. </div>
  53. </el-dialog>
  54. <el-dialog :title="title" :visible.sync="checkDialog" width="70%" append-to-body :close-on-click-modal="false">
  55. <checkMarkData :mark-data="markDataDetail" :handle-change="handleChange" :tag-label="tagLabelList" />
  56. <div slot="footer" class="dialog-footer">
  57. <!-- <el-button @click="dialogVisible = false">删除文本</el-button> -->
  58. <el-button @click="dialogVisible = false">作 废</el-button>
  59. <el-button type="primary" @click="dialogVisible = false">通 过</el-button>
  60. </div>
  61. </el-dialog>
  62. </div>
  63. </template>
  64. <script>
  65. import { getDataListApi, updataDataApi, delDataApi, PNDataApi, exportDatasetApi } from '@/api/dataMark/dataManage'
  66. import { getEntityListApi } from '@/api/dataMark/entity'
  67. import checkMarkData from './checkMarkData.vue'
  68. // import { getUserInfo } from '@/api/admin'
  69. export default {
  70. name: 'DatasetDetail',
  71. components: { checkMarkData },
  72. data() {
  73. return {
  74. queryParams: {
  75. page: 1,
  76. size: 10,
  77. dataset_id: null,
  78. id: null,
  79. text: null,
  80. is_mark: null,
  81. state: null,
  82. examine: null
  83. },
  84. dialogVisible: false,
  85. checkDialog: false,
  86. // 总条数
  87. total: 0,
  88. // 弹出层标题
  89. title: '',
  90. // 表格List
  91. dataList: [],
  92. // 表单参数
  93. form: {},
  94. rules: {},
  95. // 多选的ID
  96. ids: [],
  97. // 非单个禁用
  98. single: true,
  99. // 非多个禁用
  100. multiple: true,
  101. // 多选的序号
  102. numbers: [],
  103. userInfo: {},
  104. // 查看标注的文本
  105. markDataDetail: {},
  106. tagLabelList: []
  107. }
  108. },
  109. created() {
  110. this.queryParams.dataset_id = this.$route.params.id
  111. this.getList()
  112. this.getLabelList()
  113. },
  114. methods: {
  115. getList() {
  116. this.loading = true
  117. getDataListApi(this.queryParams).then((response) => {
  118. this.dataList = response.data.map((item, index) => ({
  119. ...item,
  120. number: index + 1
  121. }))
  122. console.log('this.dataList', this.dataList)
  123. this.total = response.total
  124. this.loading = false
  125. })
  126. },
  127. // 获取实体类和关系
  128. getLabelList() {
  129. const data = {}
  130. getEntityListApi(data).then((res) => {
  131. this.tagLabelList = res.data
  132. })
  133. },
  134. // 表单重置
  135. reset() {
  136. this.form = {
  137. id: undefined,
  138. text: undefined,
  139. is_mark: undefined,
  140. state: undefined,
  141. examine: undefined
  142. }
  143. this.resetForm('form')
  144. },
  145. /** 提交按钮 */
  146. submitForm() {
  147. this.$refs['form'].validate((valid) => {
  148. if (valid && this.form.id !== undefined && this.form.state === 0) {
  149. updataDataApi(this.form).then((response) => {
  150. this.$modal.msgSuccess('修改成功')
  151. this.dialogVisible = false
  152. this.getList()
  153. })
  154. } else {
  155. this.$modal.msgSuccess('已标注过的文本不能被修改')
  156. }
  157. })
  158. },
  159. // 删除数据集
  160. handleDelete(row) {
  161. let dataIds = []
  162. row.id ? (dataIds = [row.id]) : (dataIds = this.ids)
  163. const numbers = row.number || this.numbers
  164. this.$confirm('此操作将永久删除序号为' + numbers + '的数据, 是否继续?', '提示', {
  165. confirmButtonText: '确定',
  166. cancelButtonText: '取消',
  167. type: 'warning'
  168. }).then(async() => {
  169. await delDataApi(dataIds)
  170. this.$message({
  171. message: '删除成功!',
  172. type: 'success'
  173. })
  174. this.getList()
  175. })
  176. },
  177. // 查看标注详情
  178. handleCheck(row) {
  179. this.markDataDetail = { ...row }
  180. this.checkDialog = true
  181. this.title = '详情'
  182. },
  183. // 标注按钮
  184. beginMark(row) {
  185. this.$router.push({ name: 'markPage', params: { dataset_id: row.dataset_id, id: row.id }})
  186. },
  187. // 上一条、下一条
  188. handleChange(id, dataset_id, type) {
  189. const data = { id, dataset_id, type }
  190. PNDataApi(data).then((response) => {
  191. if (response.code === 2) {
  192. this.$message({
  193. message: response.msg,
  194. type: 'warning'
  195. })
  196. } else {
  197. this.$nextTick(() => {
  198. this.markDataDetail = response.data[0]
  199. })
  200. }
  201. })
  202. },
  203. /** 修改按钮操作 */
  204. handleUpdate(row) {
  205. this.form = { ...row }
  206. this.dialogVisible = true
  207. this.title = '修改文本内容'
  208. },
  209. // 多选框选中数据
  210. handleSelectionChange(selection) {
  211. this.ids = selection.map((item) => item.id)
  212. this.numbers = selection.map((item) => item.number)
  213. console.log('numbers', this.numbers)
  214. this.single = selection.length !== 1
  215. this.multiple = !selection.length
  216. },
  217. /** 搜索按钮操作 */
  218. handleQuery() {
  219. this.queryParams.pageNum = 1
  220. this.getList()
  221. },
  222. /** 重置按钮操作 */
  223. resetQuery() {
  224. this.resetForm('queryForm')
  225. this.handleQuery()
  226. },
  227. // 导出
  228. async handleExport() {
  229. try {
  230. this.addLoading = true
  231. const res = await exportDatasetApi(this.queryParams)
  232. this.addLoading = false
  233. this.$downFile(res)
  234. } catch (e) {
  235. this.addLoading = false
  236. }
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang="scss" scoped></style>