index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <!-- 经销商授权信息管理--列表 -->
  2. <template>
  3. <el-card class="dealerAuthorization" v-loading="loading" :body-style="{ padding: 0 }">
  4. <authprivAdd ref="addDialogRef" @close="handleRefresh"></authprivAdd>
  5. <authprivSee ref="seeDialogRef"></authprivSee>
  6. <!-- 检索区 -->
  7. <el-form :inline="true" size="mini" label-position="right" label-width="100px" :model="searchParams"
  8. style="padding: 10px 0 0 0">
  9. <el-form-item v-for="column in searchColumns " :label="column.title" :key="column.key">
  10. <el-input v-if="column.type == 'Input'" v-model="searchParams[column.key]" clearable></el-input>
  11. <el-select v-else-if="column.type == 'Select'" v-model="searchParams[column.key]" clearable>
  12. <el-option v-for="op in column.options" :label="op.label" :value="op.value"></el-option>
  13. </el-select>
  14. <el-date-picker v-else-if="column.type == 'DateRange'" v-model="searchParams[column.key]" clearable
  15. type="daterange" format="yyyy-MM-dd " value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期"
  16. end-placeholder="结束日期">
  17. </el-date-picker>
  18. <el-date-picker v-else-if="column.type == 'Date'" v-model="searchParams[column.key]" format="yyyy-MM-dd "
  19. clearable value-format="yyyy-MM-dd" type="date" :placeholder="column.config.placeholder" style="width: 192px;">
  20. </el-date-picker>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" @click="handelSearch"
  24. v-hasPermi="['pu:authorization:list']">查询</el-button>
  25. <el-button icon="el-icon-refresh" @click="handelResetSearch">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <!-- 操作区 -->
  29. <el-row :gutter="24" style="padding: 0 10px">
  30. <el-col :span="24" style="text-align: right">
  31. <el-button size="mini" type="primary" @click="handleOpenAddDialog"
  32. v-hasPermi="['pu:authorization:add']">新增</el-button>
  33. <!-- <el-button size="mini" @click="handleSubmit">提交</el-button> -->
  34. <el-button size="mini" @click="handleDownload">下载授权书</el-button>
  35. </el-col>
  36. </el-row>
  37. <!-- 数据展示 -->
  38. <el-table class="da-table" @row-dblclick="handleOpenSeeDialog" @select="handleSelect" :data="tableData"
  39. highlight-current-row max-height="500">
  40. <el-table-column type="selection" width="45"></el-table-column>
  41. <el-table-column type="index" width="55" label="序号"></el-table-column>
  42. <el-table-column v-for="column in tableColumns" :label="column.title" v-if="column.show"
  43. :width="column.width || 120" show-overflow-tooltip>
  44. <template slot-scope="scope">
  45. {{ column.key == 'status' ? judgeStatus(scope.row[column.key]) : scope.row[column.key] }}
  46. </template>
  47. </el-table-column>
  48. <el-table-column fixed="right" label="操作" width="120">
  49. <template slot-scope="scope">
  50. <el-button type="text" size="mini" @click="handleOpenAddDialog(scope.row)"
  51. v-hasPermi="['pu:authorization:edit']">编辑</el-button>
  52. <el-button type="text" size="mini" @click="handleDelDialog(scope.row)"
  53. v-if="scope.row.status == '0' || scope.row.status == '3'"
  54. v-hasPermi="['pu:authorization:remove']">删除</el-button>
  55. <!-- <el-button @click="handleOpenSeeDialog(scope.row)" type="text" size="small">查看</el-button> -->
  56. <el-button type="text" size="mini" v-if="scope.row.status == '0' || scope.row.status == '3'"
  57. @click="handleSubmit(scope.row)">提交</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="page.total"
  62. :page-sizes="pageSizes" :page-size="page.pageSize" :current-page="page.pageNum" hide-on-single-page
  63. :layout="layout">
  64. </el-pagination>
  65. </el-card>
  66. </template>
  67. <script>
  68. import dealerApi from '@/api/marketing/dealer-authorization';
  69. import { TableColumns, SearchColumns } from './column';
  70. import { initParams } from '../utils/init';
  71. export default {
  72. name: 'dealerAuthorization',
  73. components: {
  74. authprivAdd: () => import('./authprivAdd.vue'),
  75. authprivSee: () => import('./authprivSee.vue'),
  76. },
  77. data() {
  78. const initTableColumns = () => TableColumns;
  79. const initSearchColumns = () => SearchColumns;
  80. return {
  81. loading: false,
  82. searchColumns: initSearchColumns(),
  83. searchParams: {
  84. ...initParams(initSearchColumns()),
  85. },
  86. tableColumns: initTableColumns(),
  87. tableData: [],
  88. checkedList: [],
  89. page: {
  90. pageNum: 1,
  91. pageSize: 25,
  92. total: 0
  93. },
  94. pageSizes: [10, 20, 50, 100],
  95. layout: 'total, prev, pager, next, sizes, jumper',
  96. }
  97. },
  98. methods: {
  99. // 查询---列表查询
  100. async handelSearch() {
  101. this.loading = true;
  102. console.log(this.searchParams, '查询');
  103. // let isTime = this.searchParams.time && this.searchParams.time != '' && this.searchParams.time.length;
  104. let { pageNum, pageSize } = this.page;
  105. let params = {
  106. ...this.searchParams,
  107. // startTime: isTime ? this.searchParams.time[0] : '',
  108. // endTime: isTime ? this.searchParams.time[1] : '',
  109. pageNum: pageNum,
  110. pageSize: pageSize,
  111. }
  112. delete params['time']
  113. console.log(params, 'params--------');
  114. await dealerApi.list(params).then(res => {
  115. console.log(res, '获取列表');
  116. let { code, rows, total } = res;
  117. this.loading = false;
  118. if (code == 200) {
  119. this.tableData = rows;
  120. this.page.total = total;
  121. }
  122. }).catch(error => {
  123. this.loading = false;
  124. })
  125. },
  126. // 重置
  127. handelResetSearch() {
  128. console.log('重置');
  129. for (const key in this.searchParams) {
  130. this.searchParams[key] = '';
  131. }
  132. },
  133. // 判断状态
  134. judgeStatus(status) {
  135. // 单据状态0=自由态,1=审批中,2=已审核,3=已驳回
  136. let statusName = '';
  137. switch (status) {
  138. case '0':
  139. statusName = '自由态';
  140. break;
  141. case '1':
  142. statusName = '审批中';
  143. break;
  144. case '2':
  145. statusName = '已审核';
  146. break;
  147. case '3':
  148. statusName = '已驳回';
  149. break;
  150. default:
  151. break;
  152. }
  153. return statusName;
  154. },
  155. // 刷新
  156. handleRefresh() {
  157. this.handelSearch();
  158. },
  159. handleSizeChange(e) {
  160. this.page.pageSize = e;
  161. this.handelSearch();
  162. },
  163. handleCurrentChange(e) {
  164. this.page.pageNum = e;
  165. this.handelSearch();
  166. },
  167. // 选择列表
  168. handleSelect(selection, row) {
  169. console.log('selection/////////', selection, 'row/////////', row);
  170. this.checkedList = [...selection];
  171. },
  172. // 新增、编辑授权信息
  173. handleOpenAddDialog(rows) {
  174. console.log(rows, '授权信息');
  175. const { setVisible, setFormData } = this.$refs.addDialogRef;
  176. setFormData(rows);
  177. setVisible(true);
  178. },
  179. // 查看
  180. handleOpenSeeDialog(rows) {
  181. console.log(rows, '编辑、查看');
  182. const { setVisible, setFormData } = this.$refs.seeDialogRef;
  183. setFormData(rows);
  184. setVisible(true);
  185. },
  186. // 删除
  187. async handleDelDialog(rows) {
  188. console.log(rows, '删除');
  189. let { id } = rows;
  190. try {
  191. this.loading = true;
  192. let { code, msg } = await dealerApi.remove({ id });
  193. if (code == 200) {
  194. this.handleRefresh();
  195. }
  196. } catch (error) {
  197. console.log(error);
  198. } finally {
  199. this.loading = false;
  200. }
  201. },
  202. // 提交
  203. handleSubmit(row) {
  204. console.log(row, '提交');
  205. let params = {
  206. id: '',
  207. status: ''
  208. }
  209. // try {
  210. // this.loading = true;
  211. // let { code, msg } = await dealerApi.submitOA();
  212. // if (code == 200) {
  213. // this.handleRefresh();
  214. // }
  215. // } catch (error) {
  216. // console.log(error);
  217. // } finally {
  218. // this.loading = false;
  219. // }
  220. },
  221. // 下载
  222. handleDownload() {
  223. console.log('下载');
  224. // try {
  225. // let { code, msg } = await dealerApi.download();
  226. // if (code == 200) {
  227. // }
  228. // } catch (error) {
  229. // console.log(error);
  230. // } finally {}
  231. },
  232. },
  233. created() {
  234. this.handelSearch();
  235. }
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. .dealerAuthorization {
  240. width: calc(100% - 24px);
  241. height: 100%;
  242. margin: 10px;
  243. padding: 10px;
  244. box-sizing: border-box;
  245. .da-table {
  246. width: 100%;
  247. margin: 20px 0 0 0;
  248. }
  249. }
  250. </style>