audit-model-market.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div :class="[$style.wrapHeight, $style.modelMarket]">
  3. <div :class="$style.rowHeight">
  4. <a-card :class="$style.aCard">
  5. <audit-advanced-query
  6. :expand="expand"
  7. :search-data="formData"
  8. :ref-name="searchform"
  9. :search-style="{ height: '200px', left: '20px', top: '57px' }"
  10. :search-fun="handleSearch"
  11. @searchedClick="searchedClick"
  12. >
  13. <template>
  14. <a-col :span="12">
  15. <a-form-model-item :label="'模型名称'" prop="modelName">
  16. <a-input v-model="formData.modelName" allow-clear />
  17. </a-form-model-item>
  18. </a-col>
  19. <a-col :span="12">
  20. <a-form-model-item label="模型类型:" prop="modelType">
  21. <a-select
  22. v-model="formData.modelType"
  23. :class="$style.selectClass"
  24. placeholder="请选择模型类型"
  25. >
  26. <a-select-option
  27. v-for="(item, index) in tableOptions"
  28. :key="index"
  29. :value="item.id"
  30. >
  31. {{ item.name }}
  32. </a-select-option>
  33. </a-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :span="12">
  37. <a-form-model-item label="创建人:" prop="creatorAccount">
  38. <a-input v-model="formData.creatorAccount" placeholder="请输入创建人" />
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :span="12">
  42. <a-form-item label="发布时间:">
  43. <a-range-picker :key="pickerKey" :format="'YYYY-MM-DD'" @change="onTimeChange" />
  44. </a-form-item>
  45. </a-col>
  46. </template>
  47. </audit-advanced-query>
  48. <div :class="$style.modeList">
  49. <sd-data-table
  50. ref="table"
  51. :data-url="dataUrl"
  52. :columns="columns"
  53. :filter-expressions="expressions"
  54. show-advance-query
  55. :search-fields="['modelName']"
  56. @searchbtnClick="searchbtnClick"
  57. >
  58. <template slot="likeCount" slot-scope="text, record">
  59. <a-tooltip :title="text" @click="onLike(record)">
  60. <a-icon type="like" :theme="record.likeFlag === 1 ? 'twoTone' : 'outlined'" />
  61. </a-tooltip>
  62. </template>
  63. <template slot="islink" slot-scope="text, record">
  64. <a-tooltip :title="text" @click="openModelDetail(record.id)">
  65. <a>{{ text }}</a>
  66. </a-tooltip>
  67. </template>
  68. </sd-data-table>
  69. </div>
  70. </a-card>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import components from './_import-components/audit-model-market-import'
  76. import auditModelService from './audit-model-service'
  77. import TableColumnTypes from '@/common/services/table-column-types'
  78. // 引入moment
  79. import moment from 'moment'
  80. import auditAdvancedQuery from '../../components/audit-advanced-query.vue'
  81. import auditAdvancedQueryMixins from '../../components/audit-advanced-query-mixins'
  82. const modelTypeList = [
  83. {
  84. id: 0,
  85. name: '分析型',
  86. },
  87. {
  88. id: 1,
  89. name: '定位型-整改类',
  90. },
  91. {
  92. id: 2,
  93. name: '定位型-关注类',
  94. },
  95. ]
  96. export default {
  97. name: 'AuditModelMarket',
  98. metaInfo: {
  99. title: '模型市场',
  100. },
  101. components: {
  102. ...components,
  103. auditAdvancedQuery,
  104. },
  105. mixins: [auditAdvancedQueryMixins],
  106. data() {
  107. return {
  108. expressions: [],
  109. expand: false,
  110. searchform: 'searchform',
  111. pickerKey: 0,
  112. formData: {
  113. // modelName modelType creatorAccount publishDateSt publishDateEd
  114. modelName: '',
  115. modelType: '',
  116. creatorAccount: '',
  117. publishDateSt: '',
  118. publishDateEd: '',
  119. },
  120. tableOptions: modelTypeList,
  121. // 模型市场列表
  122. modelMarketList: [],
  123. // 分页器
  124. current: 1,
  125. total: 1,
  126. pageSize: 10,
  127. ifLike: false,
  128. dataUrl: 'api/xcoa-mobile/v1/iammodelmaintain/modelMarketQueryList',
  129. columns: [
  130. {
  131. dataIndex: 'modelName',
  132. title: '模型名称',
  133. scopedSlots: { customRender: 'islink' },
  134. },
  135. {
  136. dataIndex: 'creatorAccount',
  137. title: '创建人',
  138. },
  139. {
  140. dataIndex: 'modelCode',
  141. title: '模型编号',
  142. },
  143. {
  144. dataIndex: 'modelTypeName',
  145. title: '模型类型',
  146. },
  147. {
  148. dataIndex: 'publishDate',
  149. title: '发布时间',
  150. sdRender: TableColumnTypes.date,
  151. },
  152. {
  153. dataIndex: 'likeCount',
  154. title: '点赞',
  155. scopedSlots: { customRender: 'likeCount' },
  156. },
  157. ],
  158. }
  159. },
  160. methods: {
  161. handleSearch() {
  162. this.expressions = []
  163. Object.keys(this.formData).map((key) => {
  164. this.formData[key] !== '' &&
  165. this.expressions.push({
  166. dataType: 'str',
  167. name: key,
  168. op: 'eq',
  169. stringValue: this.formData[key],
  170. })
  171. })
  172. this.expressions.forEach((item) => {
  173. if (item.name === 'modelName') {
  174. item.op = 'like'
  175. item.stringValue = '%' + item.stringValue + '%'
  176. }
  177. })
  178. },
  179. // 时间变化
  180. onTimeChange(data, dataString) {
  181. const timeList = data.map((item) => {
  182. // 转化成时间戳 并忽略时分秒
  183. return moment(item._d)
  184. .startOf('day')
  185. .valueOf()
  186. })
  187. // 结束时间加一天的时间戳
  188. this.formData.publishDateSt = timeList[0]
  189. this.formData.publishDateEd = timeList[1] + 60 * 60 * 24 * 1000
  190. },
  191. // 点击点赞按钮
  192. onLike(item) {
  193. const data = {
  194. modelId: item.id,
  195. }
  196. if (this.ifLike) {
  197. return
  198. }
  199. this.ifLike = true
  200. if (item.likeFlag === 0) {
  201. auditModelService.likeModel(data).then((res) => {
  202. this.$refs.table.refresh()
  203. this.ifLike = false
  204. })
  205. } else {
  206. auditModelService.unlikeModel(data).then((res) => {
  207. this.$refs.table.refresh()
  208. this.ifLike = false
  209. })
  210. }
  211. },
  212. openModelDetail(id) {
  213. window.open('#/audit-model-view?record=' + id)
  214. },
  215. },
  216. }
  217. </script>
  218. <style module lang="scss">
  219. @use '@/common/design' as *;
  220. .wrap-height {
  221. position: relative;
  222. min-height: 100%;
  223. .row-height {
  224. display: flex;
  225. flex: auto;
  226. gap: 10px;
  227. width: 100%;
  228. height: 100%;
  229. .a-card {
  230. width: 100%;
  231. .select-class {
  232. width: 200px;
  233. }
  234. .mode-list {
  235. display: flex;
  236. flex-wrap: wrap;
  237. justify-content: space-between;
  238. padding: 0 30px;
  239. .card {
  240. width: 430px;
  241. margin: 30px;
  242. overflow: hidden;
  243. cursor: pointer;
  244. border: 1px solid #ccc;
  245. border-radius: 10px;
  246. .title {
  247. display: flex;
  248. justify-content: space-between;
  249. padding: 20px;
  250. color: #fff;
  251. background: $alert-info-icon-color;
  252. }
  253. .card-body {
  254. padding: 20px;
  255. border-bottom: 1px solid #ccc;
  256. .row {
  257. margin-top: 20px;
  258. }
  259. }
  260. .footer {
  261. display: flex;
  262. align-items: center;
  263. justify-content: flex-end;
  264. padding: 20px;
  265. }
  266. }
  267. }
  268. .pagination {
  269. display: flex;
  270. justify-content: flex-end;
  271. padding: 20px;
  272. }
  273. }
  274. }
  275. }
  276. .model-market {
  277. :global(.projectlist .ant-table-empty .ant-table-body) {
  278. overflow-x: hidden !important;
  279. }
  280. :global(span > .ant-btn:nth-child(2)) {
  281. color: #fff;
  282. background-color: #1890ff;
  283. border-color: #1890ff;
  284. }
  285. }
  286. </style>