index.vue 10 KB

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