index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-05 11:28:51
  4. * @LastEditors: wanglj
  5. * @LastEditTime: 2023-03-22 14:53:09
  6. * @FilePath: \opms_frontend\src\views\contract\index.vue
  7. -->
  8. <template>
  9. <div class="contract-container">
  10. <vab-query-form>
  11. <vab-query-form-top-panel>
  12. <el-form :inline="true" label-width="0px" :model="queryForm" @submit.native.prevent>
  13. <el-form-item prop="inchargeName">
  14. <el-input v-model="queryForm.inchargeName" clearable placeholder="对接人" @keyup.enter.native="queryData" />
  15. </el-form-item>
  16. <el-form-item prop="name">
  17. <el-input v-model="queryForm.name" clearable placeholder="联系人" @keyup.enter.native="queryData" />
  18. </el-form-item>
  19. <el-form-item prop="unit">
  20. <el-input v-model="queryForm.unit" clearable placeholder="单位" @keyup.enter.native="queryData" />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
  24. </el-form-item>
  25. </el-form>
  26. </vab-query-form-top-panel>
  27. <vab-query-form-left-panel :span="12">
  28. <el-button v-permissions="['contract:manage:add']" icon="el-icon-plus" type="primary" @click="handleEdit()">
  29. 新建
  30. </el-button>
  31. </vab-query-form-left-panel>
  32. <vab-query-form-right-panel :span="12">
  33. <table-tool :columns="columns" :show-columns.sync="showColumns" table-type="contractTable" />
  34. </vab-query-form-right-panel>
  35. </vab-query-form>
  36. <el-table ref="table" v-loading="listLoading" :data="list" :height="height">
  37. <el-table-column
  38. v-for="(item, index) in showColumns"
  39. :key="index"
  40. align="center"
  41. :label="item.label"
  42. :min-width="item.width"
  43. :prop="item.prop"
  44. show-overflow-tooltip
  45. :sortable="item.sortable">
  46. <template #default="{ row }">
  47. <el-button v-if="item.prop === 'code'" class="link-button" type="text" @click="handleDetail(row)">
  48. {{ row.code }}
  49. </el-button>
  50. <span v-else-if="item.label === '日期时间'">
  51. {{ parseTime(row.consultTime, '{y}-{m}-{d}') }}
  52. </span>
  53. <span v-else>{{ row[item.prop] }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column align="center" fixed="right" label="操作" width="140px">
  57. <template slot-scope="scope">
  58. <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
  59. <el-button type="text" @click="handleFollowUp(scope.row)">跟进</el-button>
  60. <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <el-pagination
  65. background
  66. :current-page="queryForm.pageNum"
  67. :layout="layout"
  68. :page-size="queryForm.pageSize"
  69. :total="total"
  70. @current-change="handleCurrentChange"
  71. @size-change="handleSizeChange" />
  72. <Edit ref="edit" @consultSave="consultSave" />
  73. <FollowUp ref="followUp" @consultSave="consultSave" />
  74. </div>
  75. </template>
  76. <script>
  77. import to from 'await-to-js'
  78. import consultApi from '@/api/consult'
  79. import Edit from './components/Edit'
  80. import FollowUp from './components/FollowUp'
  81. import TableTool from '@/components/table/TableTool'
  82. export default {
  83. name: 'Consult',
  84. components: {
  85. Edit,
  86. FollowUp,
  87. TableTool,
  88. },
  89. data() {
  90. return {
  91. height: this.$baseTableHeight(2),
  92. listLoading: false,
  93. layout: 'total, sizes, prev, pager, next, jumper',
  94. list: [],
  95. total: 0,
  96. queryForm: {
  97. pageNum: 1,
  98. pageSize: 10,
  99. name: '', // 联系人
  100. inchargeName: '', //对接人
  101. unit: '', //单位
  102. },
  103. selectRows: [], //选择的表格数据
  104. contractOptions: {}, //合同类型
  105. productLineOptions: {}, //产品线
  106. lines: [],
  107. // 自定义列表
  108. showColumns: [],
  109. columns: [
  110. {
  111. label: '序号',
  112. width: '160px',
  113. prop: 'code',
  114. sortable: false,
  115. disableCheck: false,
  116. },
  117. {
  118. label: '日期时间',
  119. width: '100px',
  120. prop: 'consultTime',
  121. sortable: false,
  122. disableCheck: false,
  123. },
  124. {
  125. label: '所在省',
  126. width: '200px',
  127. prop: 'province',
  128. sortable: false,
  129. disableCheck: false,
  130. },
  131. {
  132. label: '所在市',
  133. width: '100px',
  134. prop: 'city',
  135. sortable: false,
  136. disableCheck: false,
  137. },
  138. {
  139. label: '单位名称',
  140. width: '280px',
  141. prop: 'unit',
  142. sortable: false,
  143. disableCheck: false,
  144. },
  145. {
  146. label: '联系人',
  147. prop: 'name',
  148. width: '140px',
  149. },
  150. {
  151. label: '对接人',
  152. width: '120px',
  153. prop: 'inchargeName',
  154. sortable: false,
  155. disableCheck: false,
  156. },
  157. ],
  158. }
  159. },
  160. watch: {
  161. showColumns: function () {
  162. this.$nextTick(() => this.$refs.table.doLayout())
  163. },
  164. },
  165. activated() {
  166. this.queryData()
  167. },
  168. mounted() {
  169. this.queryData()
  170. this.getOptions()
  171. },
  172. methods: {
  173. getOptions() {
  174. Promise.all([this.getDicts('contract_type'), this.getDicts('sys_product_line')])
  175. .then(([contract, productLine]) => {
  176. this.contractOptions = {}
  177. contract.data.values.filter((i) => {
  178. this.contractOptions[i.key] = i.value
  179. })
  180. this.productLineOptions = {}
  181. productLine.data.values.filter((i) => {
  182. this.productLineOptions[i.key] = i.value
  183. })
  184. this.lines = productLine.data.values
  185. })
  186. .catch((err) => console.log(err))
  187. },
  188. async queryData() {
  189. this.listLoading = true
  190. const params = { ...this.queryForm }
  191. const [err, res] = await to(consultApi.list(params))
  192. if (err) return (this.listLoading = false)
  193. this.list = res.data.list || []
  194. this.total = res.data.total
  195. this.listLoading = false
  196. this.$nextTick(() => this.$refs.table.doLayout())
  197. },
  198. reset() {
  199. this.queryForm = {
  200. pageNum: 1,
  201. pageSize: 10,
  202. name: '', // 联系人
  203. inchargeName: '', //对接人
  204. unit: '', //单位
  205. }
  206. this.queryData()
  207. },
  208. handleSizeChange(val) {
  209. this.queryForm.pageSize = val
  210. this.queryData()
  211. },
  212. handleCurrentChange(val) {
  213. this.queryForm.pageNum = val
  214. this.queryData()
  215. },
  216. async handleEdit(row = null) {
  217. row ? this.$refs.edit.init(row.id) : this.$refs.edit.init()
  218. },
  219. async handleFollowUp(row = null) {
  220. row ? this.$refs.followUp.init(row.id) : this.$refs.followUp.init()
  221. },
  222. handleDetail(row) {
  223. this.$router.push({
  224. path: '/consult/detail',
  225. query: {
  226. id: row.id,
  227. },
  228. })
  229. },
  230. handleDelete(row) {
  231. let ids = [row.id]
  232. this.$confirm('确认删除?', '提示', {
  233. confirmButtonText: '确定',
  234. cancelButtonText: '取消',
  235. type: 'warning',
  236. })
  237. .then(async () => {
  238. const [err, res] = await to(consultApi.delete({ id: ids }))
  239. if (err) return
  240. if (res.code == 200) {
  241. this.$message({
  242. type: 'success',
  243. message: '删除成功!',
  244. })
  245. this.queryData()
  246. }
  247. })
  248. .catch(() => {})
  249. },
  250. consultSave(createProj) {
  251. this.queryData()
  252. if (createProj) {
  253. this.$router.push({
  254. path: '/opportunity/business',
  255. })
  256. }
  257. },
  258. },
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. $base: '.contract-container';
  263. </style>