indexCompanyCase.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" v-if="hasPerm('companyCaseIndex:page')">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="名称">
  8. <a-input v-model="queryParam.name" allow-clear placeholder="请输入名称搜索"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="16" :sm="24">
  12. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  13. <a-button type="primary" style="margin-left: 8px" v-if="hasPerm('companyCaseIndex:add')" icon="plus" @click="$refs.addForm.add()">新增</a-button>
  14. </a-col>
  15. </a-row>
  16. </a-form>
  17. </div>
  18. <s-table
  19. ref="table"
  20. size="default"
  21. :columns="columns"
  22. :data="loadData"
  23. :alert="true"
  24. :rowKey="(record) => record.companyId"
  25. >
  26. <span slot="companyName" slot-scope="text">
  27. <ellipsis :length="30" tooltip>{{ text }}</ellipsis>
  28. </span>
  29. <span slot="companyDescribe" slot-scope="text">
  30. <ellipsis :length="50" tooltip>{{ text }}</ellipsis>
  31. </span>
  32. <span slot="companyDefaultImg" slot-scope="src">
  33. <img :src="src | getImgUrl" width="60" height="45" @click="showPreviewImg(src)" style="cursor: pointer;"/>
  34. </span>
  35. <span slot="companyExchangeImg" slot-scope="src">
  36. <img :src="src | getImgUrl" width="60" height="45" @click="showPreviewImg(src)" style="cursor: pointer;"/>
  37. </span>
  38. <span slot="companyAssociatedCase" slot-scope="text, record">
  39. <span @click="goUrl(record)" class="urlSpan">{{ text }}</span>
  40. </span>
  41. <!-- <span slot="companyJumpUrl" slot-scope="text">
  42. <ellipsis :length="80" tooltip>{{ text }}</ellipsis>
  43. </span> -->
  44. <span slot="action" slot-scope="text, record">
  45. <a-popconfirm placement="top" :title="record.companyIsLine===1? '是否确认下线该条目?':'是否确认上线该条目?'" @confirm="() => editjobStatusStatus(record.companyIsLine,record)">
  46. <a>{{ statusFilter(record.companyIsLine) }}</a>
  47. </a-popconfirm>
  48. <a-divider type="vertical"/>
  49. <a v-if="hasPerm('companyCaseIndex:edit')" @click="$refs.editForm.edit(record)">编辑</a>
  50. <a-divider type="vertical" v-if="hasPerm('companyCaseIndex:edit') && hasPerm('companyCaseIndex:delete')"/>
  51. <a-popconfirm v-if="hasPerm('companyCaseIndex:delete')" placement="topRight" title="是否确认删除该条目?" @confirm="() => companyCaseIndexDelete(record)">
  52. <a>删除</a>
  53. </a-popconfirm>
  54. </span>
  55. </s-table>
  56. <add-form ref="addForm" @ok="handleOk" />
  57. <edit-form ref="editForm" @ok="handleOk" />
  58. <detail-show ref="articleForm"></detail-show>
  59. <a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel" title="预览">
  60. <img alt="example" style="width: 100%" :src="previewImage" />
  61. </a-modal>
  62. </a-card>
  63. </template>
  64. <script>
  65. import { STable, Ellipsis } from '@/components'
  66. import homeApi from '@/api/homeApi'
  67. import { setImgUrl } from '@/utils/img'
  68. import addForm from './addCompanyCaseForm'
  69. import editForm from './editCompanyCaseForm'
  70. import detailShow from '@/views/constrolContent/detailShow'
  71. const _ = require('lodash')
  72. export default {
  73. name: 'CompanyCaseIndex',
  74. components: {
  75. STable,
  76. Ellipsis,
  77. detailShow,
  78. addForm,
  79. editForm
  80. },
  81. data () {
  82. return {
  83. // 查询参数
  84. queryParam: { id: '' },
  85. // 表头
  86. columns: [
  87. {
  88. title: '序号',
  89. dataIndex: 'dataIndex',
  90. customRender: (text, row, index) => {
  91. return index + 1
  92. },
  93. align: 'center',
  94. width: '90px'
  95. },
  96. {
  97. title: '名称',
  98. dataIndex: 'companyName',
  99. scopedSlots: { customRender: 'companyName' }
  100. },
  101. {
  102. title: '描述',
  103. dataIndex: 'companyDescribe',
  104. scopedSlots: { customRender: 'companyDescribe' }
  105. },
  106. {
  107. title: '默认图片',
  108. dataIndex: 'companyDefaultImg',
  109. scopedSlots: { customRender: 'companyDefaultImg' },
  110. align: 'center',
  111. width: '150px'
  112. },
  113. {
  114. title: '交互图片',
  115. dataIndex: 'companyExchangeImg',
  116. scopedSlots: { customRender: 'companyExchangeImg' },
  117. align: 'center',
  118. width: '150px'
  119. },
  120. {
  121. title: '关联案例',
  122. dataIndex: 'companyAssociatedCaseShow',
  123. scopedSlots: { customRender: 'companyAssociatedCase' }
  124. },
  125. // {
  126. // title: '跳转链接',
  127. // dataIndex: 'companyJumpUrl',
  128. // scopedSlots: { customRender: 'companyJumpUrl' }
  129. // },
  130. {
  131. title: '排序',
  132. dataIndex: 'companySort',
  133. align: 'center',
  134. width: '90px'
  135. }
  136. ],
  137. // 加载数据方法 必须为 Promise 对象
  138. loadData: parameter => {
  139. return homeApi.findCompanyCaseById(Object.assign(parameter, this.queryParam)).then((res) => {
  140. var data = res.data
  141. _.each(data.rows, (item, index) => {
  142. item.companyAssociatedCaseShow = JSON.parse(item.companyAssociatedCase).articleContentTitle || JSON.parse(item.companyAssociatedCase).articleContentClassify
  143. })
  144. return data
  145. })
  146. },
  147. selectedRowKeys: [],
  148. selectedRows: [],
  149. statusDictTypeDropDown: [{ code: 0, name: '下线' }, { code: 1, name: '上线' }],
  150. previewVisible: false,
  151. previewImage: ''
  152. }
  153. },
  154. created () {
  155. if (this.hasPerm('companyCaseIndex:edit') || this.hasPerm('companyCaseIndex:delete') || hasPerm('companyCaseIndex:start') || hasPerm('companyCaseIndex:stop')) {
  156. this.columns.push({
  157. title: '操作',
  158. width: '150px',
  159. dataIndex: 'action',
  160. scopedSlots: { customRender: 'action' }
  161. })
  162. }
  163. },
  164. filters: {
  165. getImgUrl (v) {
  166. return setImgUrl(v)
  167. }
  168. },
  169. methods: {
  170. statusFilter (status) {
  171. const values = this.statusDictTypeDropDown.filter(item => item.code === status)
  172. if (values.length > 0) {
  173. return values[0].name
  174. } else {
  175. return '上线'
  176. }
  177. },
  178. /**
  179. * 启动停止
  180. */
  181. editjobStatusStatus (code, record) {
  182. if (code === 1) {
  183. homeApi.updateIsLineCompanyCase({ id: record.companyId, isLine: 0 }).then(res => {
  184. if (res.status === 200) {
  185. if (res.data) {
  186. this.$message.success('下线成功')
  187. this.$refs.table.refresh()
  188. } else {
  189. this.$message.error('下线失败')
  190. }
  191. } else {
  192. this.$message.error('下线失败:' + res.msg)
  193. }
  194. })
  195. } else {
  196. homeApi.updateIsLineCompanyCase({ id: record.companyId, isLine: 1 }).then(res => {
  197. if (res.status === 200) {
  198. if (res.data) {
  199. this.$message.success('上线成功')
  200. this.$refs.table.refresh()
  201. } else {
  202. this.$message.error('上线失败')
  203. }
  204. } else {
  205. this.$message.error('上线失败:' + res.msg)
  206. }
  207. })
  208. }
  209. },
  210. companyCaseIndexDelete (record) {
  211. homeApi.deleteCompanyCase({ id: record.companyId }).then((res) => {
  212. if (res.status === 200) {
  213. if (res.data) {
  214. this.$message.success('删除成功')
  215. this.$refs.table.refresh()
  216. } else {
  217. this.$message.error('删除失败')
  218. }
  219. } else {
  220. this.$message.error('删除失败:' + res.msg)
  221. }
  222. }).catch((err) => {
  223. this.$message.error('删除错误:' + err.message)
  224. })
  225. },
  226. goUrl (item) {
  227. this.$refs.articleForm.show({ id: JSON.parse(item.companyAssociatedCase).articleContentId })
  228. },
  229. handleOk () {
  230. this.$refs.table.refresh()
  231. },
  232. onSelectChange (selectedRowKeys, selectedRows) {
  233. this.selectedRowKeys = selectedRowKeys
  234. this.selectedRows = selectedRows
  235. },
  236. showPreviewImg (src) {
  237. this.previewImage = setImgUrl(src)
  238. this.previewVisible = true
  239. },
  240. handleCancel () {
  241. this.previewVisible = false
  242. }
  243. }
  244. }
  245. </script>
  246. <style lang="less">
  247. .table-operator {
  248. margin-bottom: 18px;
  249. }
  250. button {
  251. margin-right: 8px;
  252. }
  253. .urlSpan{
  254. cursor:pointer;
  255. }
  256. .urlSpan:hover{
  257. text-decoration: underline;
  258. }
  259. </style>