index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div class="screen-container">
  5. <el-form
  6. ref="screenForm"
  7. :model="screenForm"
  8. label-width="60px"
  9. size="small"
  10. label-position="left"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="18" :lg="18">
  14. <el-form-item label="标题" prop="title">
  15. <el-input
  16. v-model="screenForm.title"
  17. placeholder="请输入标题"
  18. ></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="6" :lg="6" class="tr">
  22. <el-form-item label="">
  23. <el-button size="small" @click="resetScreenForm">清空</el-button>
  24. <el-button size="small" type="primary" @click="submitScreenForm"
  25. >搜索</el-button
  26. >
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. </el-form>
  31. </div>
  32. <div class="mymain-container">
  33. <div class="btn-group clearfix">
  34. <div class="fl">
  35. <el-button
  36. class="fl"
  37. size="small"
  38. type="primary"
  39. icon="el-icon-plus"
  40. @click="clickImport()"
  41. v-if="$checkBtnRole('add', $route.meta.roles)"
  42. >新增</el-button
  43. >
  44. <div class="tips fl">
  45. 导入模板第一行必须为空白行、第一列必须为经销商编号(S9219801)
  46. </div>
  47. </div>
  48. </div>
  49. <div class="table">
  50. <el-table
  51. v-loading="listLoading"
  52. :data="dataList"
  53. element-loading-text="Loading"
  54. border
  55. fit
  56. highlight-current-row
  57. stripe
  58. >
  59. <el-table-column
  60. align="center"
  61. label="操作"
  62. fixed="right"
  63. width="160"
  64. >
  65. <template slot-scope="scope">
  66. <el-button
  67. type="text"
  68. @click="openDetail(scope.row.id)"
  69. v-if="checkBtnRole('edit')"
  70. >详情</el-button
  71. >
  72. <el-button
  73. type="text"
  74. @click="handleExport(scope.row)"
  75. v-if="checkBtnRole('edit')"
  76. >下载</el-button
  77. >
  78. <el-popconfirm
  79. style="margin-left: 10px"
  80. title="确定删除吗?"
  81. @onConfirm="deleteData(scope.row.id)"
  82. v-if="$checkBtnRole('del', $route.meta.roles)"
  83. >
  84. <el-button slot="reference" type="text">删除</el-button>
  85. </el-popconfirm>
  86. </template>
  87. </el-table-column>
  88. <el-table-column
  89. align="center"
  90. label="标题"
  91. prop="title"
  92. min-width="140"
  93. show-overflow-tooltip
  94. ></el-table-column>
  95. <el-table-column
  96. align="center"
  97. label="操作人"
  98. prop="operatorUserName"
  99. min-width="140"
  100. show-overflow-tooltip
  101. >
  102. <template slot-scope="scope">
  103. {{ scope.row.operatorNickName }}({{ scope.row.operatorUserName }})
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. align="center"
  108. prop="remark"
  109. label="备注"
  110. min-width="140"
  111. show-overflow-tooltip
  112. ></el-table-column>
  113. <el-table-column
  114. align="center"
  115. label="创建时间"
  116. prop="createTime"
  117. min-width="160"
  118. show-overflow-tooltip
  119. ></el-table-column>
  120. </el-table>
  121. </div>
  122. <div class="pagination clearfix">
  123. <div class="fr">
  124. <el-pagination
  125. @size-change="handleSizeChange"
  126. @current-change="handleCurrentChange"
  127. :current-page="currentPage"
  128. :page-sizes="[10, 20, 30, 50]"
  129. :page-size="10"
  130. layout="total, sizes, prev, pager, next, jumper"
  131. :total="listTotal"
  132. >
  133. </el-pagination>
  134. </div>
  135. </div>
  136. </div>
  137. <!-- 新增 -->
  138. <el-dialog
  139. title="新增"
  140. :visible.sync="importFormDialog"
  141. :show-close="false"
  142. width="40%"
  143. :close-on-click-modal="false"
  144. >
  145. <el-form ref="importForm" label-position="left" label-width="80px">
  146. <el-form-item label="标题" prop="title">
  147. <el-input
  148. v-model="importForm.title"
  149. placeholder="请输入标题"
  150. ></el-input>
  151. </el-form-item>
  152. <el-form-item label="上传文件" prop="fileUrl">
  153. <FileUpload :fileList="fileList" :fileType="['excel']" />
  154. </el-form-item>
  155. <el-form-item label="备注" prop="remark">
  156. <el-input
  157. type="textarea"
  158. v-model="importForm.remark"
  159. placeholder="请输入备注"
  160. ></el-input>
  161. </el-form-item>
  162. </el-form>
  163. <div slot="footer" class="dialog-footer">
  164. <el-button @click="cancelImportForm">取 消</el-button>
  165. <el-button type="primary" @click="submitImportForm">确 定</el-button>
  166. </div>
  167. </el-dialog>
  168. <!-- 详情 -->
  169. <el-dialog
  170. title="详情"
  171. :visible.sync="detailDialog"
  172. :show-close="false"
  173. width="70%"
  174. :close-on-click-modal="false"
  175. >
  176. <div class="table" style="margin: 10px 0 20px">
  177. <el-table
  178. v-loading="detailTable_listLoading"
  179. :data="detailTable_dataList"
  180. element-loading-text="Loading"
  181. tooltip-effect="dark"
  182. style="width: 100%"
  183. max-height="270"
  184. >
  185. <el-table-column
  186. align="center"
  187. label="序号"
  188. type="index"
  189. width="50"
  190. ></el-table-column>
  191. <el-table-column
  192. align="center"
  193. prop="title"
  194. label="标题"
  195. min-width="140"
  196. show-overflow-tooltip
  197. ></el-table-column>
  198. <el-table-column
  199. align="center"
  200. prop="adminNickName"
  201. label="下载人"
  202. min-width="140"
  203. show-overflow-tooltip
  204. ></el-table-column>
  205. <el-table-column
  206. align="center"
  207. prop="remark"
  208. label="备注"
  209. min-width="140"
  210. show-overflow-tooltip
  211. ></el-table-column>
  212. <el-table-column
  213. align="center"
  214. prop="createTime"
  215. label="下载时间"
  216. min-width="160"
  217. ></el-table-column>
  218. </el-table>
  219. </div>
  220. <div class="pagination clearfix">
  221. <div class="fr">
  222. <el-pagination
  223. @current-change="detailTableCurrentChange"
  224. :current-page="detailTable_currentPage"
  225. :page-size="detailTable_pageSize"
  226. background
  227. layout="prev, pager, next"
  228. :total="detailTable_listTotal"
  229. >
  230. </el-pagination>
  231. </div>
  232. </div>
  233. <div slot="footer" class="dialog-footer">
  234. <el-button @click="detailDialog = false">关 闭</el-button>
  235. </div>
  236. </el-dialog>
  237. </div>
  238. </template>
  239. <script>
  240. import { getToken } from "@/utils/auth";
  241. import {
  242. getList,
  243. getDownloadList,
  244. deleteData,
  245. exportFile,
  246. handleImport,
  247. } from "@/api/issue";
  248. import FileUpload from "@/components/Common/file-upload.vue";
  249. export default {
  250. components: {
  251. FileUpload,
  252. },
  253. data() {
  254. return {
  255. imageURL: this.$imageUrl,
  256. dataList: null, // 列表数据
  257. listLoading: true, // 列表加载loading
  258. currentPage: 1, // 当前页码
  259. pageSize: 10, // 每页数量
  260. listTotal: 0, // 列表总数
  261. screenForm: {
  262. // 筛选表单数据
  263. title: "",
  264. },
  265. importForm: {
  266. title: "",
  267. remark: "",
  268. },
  269. importFormDialog: false,
  270. fileList: [],
  271. detailDialog: false, // 详情 - 弹窗
  272. detailTable_dataList: null, // 详情 - 列表数据
  273. detailTable_listLoading: true, // 详情 - 列表加载loading
  274. detailTable_currentPage: 1, // 详情 - 当前页码
  275. detailTable_pageSize: 10, // 详情 - 每页数量
  276. detailTable_listTotal: 0, // 详情 - 列表总数
  277. };
  278. },
  279. computed: {},
  280. created() {
  281. this.getList();
  282. },
  283. methods: {
  284. // 查询按钮权限
  285. checkBtnRole(value) {
  286. return true;
  287. let btnRole = this.$route.meta.roles;
  288. if (!btnRole) {
  289. return true;
  290. }
  291. let index = btnRole.indexOf(value);
  292. return index >= 0 ? true : false;
  293. },
  294. // 获取列表
  295. getList() {
  296. this.listLoading = true;
  297. let params = {
  298. pageNo: this.currentPage,
  299. pageSize: this.pageSize,
  300. title: this.screenForm.title,
  301. };
  302. getList(params).then((res) => {
  303. this.listLoading = false;
  304. this.dataList = res.data ? res.data.records : [];
  305. this.listTotal = res.data ? res.data.total : 0;
  306. });
  307. },
  308. // 更改每页数量
  309. handleSizeChange(val) {
  310. this.pageSize = val;
  311. this.currentPage = 1;
  312. this.getList();
  313. },
  314. // 更改当前页
  315. handleCurrentChange(val) {
  316. this.currentPage = val;
  317. this.getList();
  318. },
  319. // 提交筛选表单
  320. submitScreenForm() {
  321. this.currentPage = 1;
  322. this.getList();
  323. },
  324. // 重置筛选表单
  325. resetScreenForm() {
  326. this.$refs.screenForm.resetFields();
  327. this.currentPage = 1;
  328. this.getList();
  329. },
  330. // 操作 - 删除
  331. deleteData(id) {
  332. deleteData({ id }).then((res) => {
  333. this.getList();
  334. this.$successMsg();
  335. });
  336. },
  337. // 详情 - 获取列表
  338. getDownloadList() {
  339. getDownloadList({
  340. pageNo: this.detailTable_currentPage,
  341. pageSize: this.detailTable_pageSize,
  342. id: this.detailId,
  343. }).then((res) => {
  344. this.detailTable_dataList = res.data.records;
  345. this.detailTable_listTotal = res.data.total;
  346. this.detailTable_listLoading = false;
  347. });
  348. },
  349. // 详情 - 打开弹窗
  350. openDetail(id) {
  351. this.detailId = id;
  352. this.detailDialog = true;
  353. this.detailTable_currentPage = 1;
  354. this.getDownloadList();
  355. },
  356. // 详情 - 更改列表当前页
  357. detailTableCurrentChange(val) {
  358. this.detailTable_currentPage = val;
  359. this.getDownloadList();
  360. },
  361. // 点击导入
  362. clickImport() {
  363. this.importFormDialog = true;
  364. },
  365. // 取消 导入
  366. cancelImportForm() {
  367. this.importFormDialog = false;
  368. this.fileList = [];
  369. this.importForm.title = "";
  370. this.importForm.remark = "";
  371. },
  372. // 导入
  373. async submitImportForm() {
  374. if (!this.importForm.title) {
  375. return this.$errorMsg("请填写标题");
  376. }
  377. if (this.fileList.length <= 0) {
  378. return this.$errorMsg("请上传文件");
  379. }
  380. const loading = this.$loading({
  381. lock: true,
  382. text: "Loading",
  383. spinner: "el-icon-loading",
  384. background: "rgba(0, 0, 0, 0.7)",
  385. });
  386. const formData = {
  387. file: this.fileList[0].url,
  388. title: this.importForm.title,
  389. remark: this.importForm.remark,
  390. };
  391. handleImport(formData)
  392. .then((res) => {
  393. this.fileList = [];
  394. this.getList();
  395. this.importFormDialog = false;
  396. })
  397. .catch((res) => {
  398. this.$errorMsg(res.message);
  399. })
  400. .finally((res) => {
  401. loading.close();
  402. });
  403. },
  404. // 下载
  405. handleExport(item) {
  406. exportFile({ id: item.id }).then((res) => {
  407. if (res.data) {
  408. window.open(this.imageURL + res.data);
  409. }
  410. });
  411. },
  412. },
  413. };
  414. </script>
  415. <style scoped>
  416. .tips {
  417. font-size: 14px;
  418. color: red;
  419. line-height: 32px;
  420. margin-left: 10px;
  421. }
  422. </style>