list.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-control">
  5. <span>商品名称:</span>
  6. <el-input v-model="listQuery.productName" style="width:130px;" placeholder="商品名称" clearable @keyup.enter.native="getList" @clear="getList" />
  7. </div>
  8. <div class="filter-control">
  9. <span>发起机构:</span>
  10. <el-input v-model="listQuery.linkMan" style="width:130px;" placeholder="发起机构" clearable @keyup.enter.native="getList" @clear="getList" />
  11. </div>
  12. <div class="filter-control">
  13. <span>需求状态:</span>
  14. <el-select v-model="listQuery.status" style="width:120px;" clearable @change="getList">
  15. <el-option value="" label="全部" />
  16. <el-option label="未完成" :value="0" />
  17. <el-option label="已完成" :value="1" />
  18. <el-option label="已删除" :value="3" />
  19. </el-select>
  20. </div>
  21. <div class="filter-control">
  22. <span>发布日期:</span>
  23. <el-date-picker
  24. v-model="registTime"
  25. type="daterange"
  26. unlink-panels
  27. range-separator="至"
  28. start-placeholder="开始日期"
  29. end-placeholder="结束日期"
  30. :picker-options="pickerOptions"
  31. @change="getList"
  32. />
  33. </div>
  34. <div class="filter-control">
  35. <el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
  36. </div>
  37. </div>
  38. <el-table
  39. v-loading="listLoading"
  40. :data="list"
  41. element-loading-text="Loading"
  42. border
  43. fit
  44. highlight-current-row
  45. :header-cell-style="{background:'#eef1f6',color:'#606266'}"
  46. >
  47. <el-table-column label="采购商品" width="220" align="center" prop="productName" />
  48. <el-table-column label="图片" align="center" width="100">
  49. <template slot-scope="{ row }">
  50. <el-popover
  51. placement="top-start"
  52. title=""
  53. width="120"
  54. trigger="hover"
  55. >
  56. <img :src="row.productImage" alt="" style="width:100px;height:100px;">
  57. <img slot="reference" :src="row.productImage" alt="" style="width:50px;height:50px;">
  58. </el-popover>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="发起机构" align="center" prop="clubName" />
  62. <el-table-column label="联系人" width="100" align="center" prop="linkMan" />
  63. <el-table-column label="手机号" width="140" align="center" prop="mobile" />
  64. <el-table-column label="参与机构数" width="100" align="center" prop="clubCount" />
  65. <el-table-column label="需求数量" width="100" align="center" prop="needNum" />
  66. <el-table-column label="状态" width="150" align="center" prop="status">
  67. <template slot-scope="{ row }">
  68. <span
  69. :class="{
  70. 'el-span-warning': row.status == 1,
  71. 'el-span-success': row.status == 2,
  72. 'el-span-danger': row.status == 3,
  73. }"
  74. >
  75. {{ row.status | statusFilters }}
  76. </span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column align="center" label="发布时间" prop="saveTime" width="100" />
  80. <el-table-column label="操作" align="center" width="300">
  81. <template slot-scope="{row}">
  82. <el-button type="primary" size="mini" @click="handleDetail(row)">查看详情</el-button>
  83. <el-button v-if="row.status === 1" type="warning" size="mini" @click="hanleVerify(row)">置为已完成</el-button>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <!-- 页码 -->
  88. <pagination
  89. v-show="total>10"
  90. :total="total"
  91. :page-sizes="[10]"
  92. :page-size="10"
  93. :page.sync="listQuery.pageNum"
  94. :limit.sync="listQuery.pageSize"
  95. @pagination="getList"
  96. />
  97. </div>
  98. </template>
  99. <script>
  100. import { getList, buyDone } from '@/api/centralized'
  101. import pickerOptions from '@/utils/time-picker.js'
  102. export default {
  103. filters: {
  104. statusFilters(value) {
  105. console.log('value', value)
  106. // 处理状态显示
  107. const map = {
  108. 1: '未完成',
  109. 2: '已完成',
  110. 3: '已删除'
  111. }
  112. return map[value]
  113. }
  114. },
  115. data() {
  116. return {
  117. registTime: '',
  118. pickerOptions,
  119. list: [],
  120. listLoading: true,
  121. total: 0,
  122. listQuery: {
  123. pageNum: 1,
  124. pageSize: 10,
  125. productName: '',
  126. status: '',
  127. clubName: '',
  128. startSaveTime: '',
  129. endSaveTime: ''
  130. }
  131. }
  132. },
  133. computed: {
  134. disabled() {
  135. return !this.addPeople.status
  136. },
  137. organizeId() {
  138. return this.$store.getters.organizeId
  139. }
  140. },
  141. created() {
  142. this.getList()
  143. },
  144. methods: {
  145. initTime() {
  146. // 初始化获取时间筛选值
  147. if (this.registTime && this.registTime.length > 0) {
  148. this.listQuery.startSaveTime = this.registTime[0]
  149. this.listQuery.endSaveTime = this.registTime[1]
  150. } else {
  151. this.listQuery.startSaveTime = ''
  152. this.listQuery.endSaveTime = ''
  153. }
  154. },
  155. async getList() {
  156. this.listLoading = true
  157. try {
  158. this.initTime()
  159. const res = await getList(this.listQuery)
  160. this.list = res.data.results
  161. this.total = res.data.totalRecord
  162. this.listLoading = false
  163. } catch (error) {
  164. console.log('error', error)
  165. this.listLoading = false
  166. }
  167. },
  168. // 置为已完成
  169. hanleVerify(row) {
  170. this.$confirm('确定将该需求置为已完成吗?', '提示', {
  171. confirmButtonText: '确定',
  172. cancelButtonText: '取消',
  173. type: 'warning'
  174. }).then(() => {
  175. this.buyDone(row.id)
  176. })
  177. },
  178. // 调用
  179. async buyDone(id) {
  180. try {
  181. await buyDone({ id: id })
  182. this.$message.success('操作成功')
  183. this.getList()
  184. } catch (error) {
  185. console.log('error', error)
  186. }
  187. },
  188. // 集采详情
  189. handleDetail(row) {
  190. this.$router.push({ path: '/centralized/details', query: { id: row.id }})
  191. },
  192. handleFilter() {
  193. this.fetchData()
  194. }
  195. }
  196. }
  197. </script>
  198. <style scoped>
  199. .el-dialog{
  200. width: 600px;
  201. }
  202. </style>