123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class="body">
  3. <div class="noshadowCard">
  4. <el-card class="box-card">
  5. 实例名称:<el-input
  6. v-model="name"
  7. size="mini"
  8. style="width: 150px; margin-right: 20px"
  9. />
  10. 创建时间:
  11. <el-date-picker
  12. v-model="daterange"
  13. size="mini"
  14. type="daterange"
  15. range-separator="至"
  16. start-placeholder="开始日期"
  17. end-placeholder="结束日期"
  18. value-format="yyyy-MM-dd"
  19. @change="dateChange"
  20. style="width:220px; margin-right: 20px"
  21. >
  22. </el-date-picker>
  23. <el-button type="primary" size="mini" @click="onSearch">查询</el-button>
  24. <el-button size="mini" @click="onReset">重置</el-button>
  25. <el-button type="primary" size="mini" @click="handleAddRusult">添加实例</el-button>
  26. </el-card>
  27. </div>
  28. <el-table stripe :data="tableData" border style="width: 100%">
  29. <el-table-column prop="name" label="实例名称" />
  30. <el-table-column prop="thumb" label="图片">
  31. <template slot-scope="scope">
  32. <el-image
  33. :src="scope.row.thumb"
  34. style="width: 100px; height: 100px"
  35. />
  36. </template>
  37. </el-table-column>
  38. <el-table-column fixed="right" label="操作">
  39. <template slot-scope="scope">
  40. <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
  41. <el-popconfirm
  42. icon="el-icon-info"
  43. icon-color="red"
  44. title="这个实例确定删除吗?"
  45. @onConfirm="handleDelete(scope.row)"
  46. >
  47. <el-button type="text" slot="reference">删除</el-button>
  48. </el-popconfirm>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. </div>
  53. </template>
  54. <script>
  55. import {
  56. getCharacterResultList,
  57. deleteCharacterResult,
  58. } from "@/api/characterLib";
  59. export default {
  60. props: {
  61. libId: String,
  62. },
  63. data() {
  64. return {
  65. name: undefined,
  66. daterange:'',
  67. tableData: [],
  68. endDate:undefined,
  69. startDate:undefined
  70. };
  71. },
  72. watch: {
  73. libId: function () {
  74. this.onSearch();
  75. },
  76. },
  77. methods: {
  78. //添加实例
  79. handleAddRusult() {
  80. this.$emit("handleAddRusult", true);
  81. },
  82. handleEdit(row) {
  83. // 向外传送数据row.resultId
  84. this.$emit("handleEdit", row.resultId);
  85. },
  86. handleDelete(row) {
  87. deleteCharacterResult(row.resultId).then(() => {
  88. this.$message("删除实例成功");
  89. this.onSearch();
  90. //关闭编辑实例页面防止编辑页面还没关闭就删除当前实例了
  91. this.$emit("handleClose", true);
  92. });
  93. },
  94. onSearch() {
  95. getCharacterResultList({ libId: this.libId, name: this.name ,startDate:this.startDate,endDate:this.endDate}).then(
  96. (res) => {
  97. this.tableData = res.data.records;
  98. }
  99. );
  100. },
  101. onReset() {
  102. this.name = "";
  103. this.daterange = "";
  104. this.startDate = "";
  105. this.endDate = "";
  106. this.onSearch();
  107. },
  108. dateChange(val){
  109. this.startDate=this.daterange[0]
  110. this.endDate=this.daterange[1]
  111. }
  112. },
  113. };
  114. </script>
  115. <style>
  116. .noshadowCard > .box-card {
  117. box-shadow: none;
  118. }
  119. </style>