issue.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :optionsEvensGroup="optionsEvensGroup"
  6. :exportList="exportList"
  7. :operation="operation()"
  8. :columnParsing="columnParsing"
  9. >
  10. <template #moreSearch>
  11. <div class="tips fl">导入模板第一行必须为空白行、第一列必须为经销商编号</div>
  12. </template>
  13. <!-- 新增 -->
  14. <el-dialog
  15. title="新增"
  16. :visible.sync="importFormDialog"
  17. :show-close="false"
  18. width="40%"
  19. :close-on-click-modal="false"
  20. >
  21. <el-form ref="importForm" label-position="left" label-width="80px">
  22. <el-form-item label="标题" prop="title">
  23. <el-input v-model="importForm.title" placeholder="请输入标题"></el-input>
  24. </el-form-item>
  25. <el-form-item label="上传文件" prop="fileUrl">
  26. <FileUpload :fileList="fileList" :fileType="['excel']" />
  27. </el-form-item>
  28. <el-form-item label="备注" prop="remark">
  29. <el-input type="textarea" v-model="importForm.remark" placeholder="请输入备注"></el-input>
  30. </el-form-item>
  31. </el-form>
  32. <div slot="footer" class="dialog-footer">
  33. <el-button @click="cancelImportForm">取 消</el-button>
  34. <el-button type="primary" @click="submitImportForm">确 定</el-button>
  35. </div>
  36. </el-dialog>
  37. <!-- 详情 -->
  38. <el-dialog title="详情" :visible.sync="detailDialog" :show-close="false" width="70%" :close-on-click-modal="false">
  39. <div class="table" style="margin: 10px 0 20px">
  40. <el-table
  41. v-loading="detailTable_listLoading"
  42. :data="detailTable_dataList"
  43. element-loading-text="Loading"
  44. tooltip-effect="dark"
  45. style="width: 100%"
  46. max-height="270"
  47. >
  48. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  49. <el-table-column
  50. align="center"
  51. prop="title"
  52. label="标题"
  53. min-width="140"
  54. show-overflow-tooltip
  55. ></el-table-column>
  56. <el-table-column
  57. align="center"
  58. prop="adminNickName"
  59. label="下载人"
  60. min-width="140"
  61. show-overflow-tooltip
  62. ></el-table-column>
  63. <el-table-column
  64. align="center"
  65. prop="remark"
  66. label="备注"
  67. min-width="140"
  68. show-overflow-tooltip
  69. ></el-table-column>
  70. <el-table-column align="center" prop="createTime" label="下载时间" min-width="160"></el-table-column>
  71. </el-table>
  72. </div>
  73. <div class="pagination clearfix">
  74. <div class="fr">
  75. <el-pagination
  76. @current-change="detailTableCurrentChange"
  77. :current-page="detailTable_currentPage"
  78. :page-size="detailTable_pageSize"
  79. background
  80. layout="prev, pager, next"
  81. :total="detailTable_listTotal"
  82. >
  83. </el-pagination>
  84. </div>
  85. </div>
  86. <div slot="footer" class="dialog-footer">
  87. <el-button @click="detailDialog = false">关 闭</el-button>
  88. </div>
  89. </el-dialog>
  90. </template-page>
  91. </template>
  92. <script>
  93. import TemplatePage from '@/components/template/template-page-1.vue'
  94. import import_mixin from '@/components/template/import_mixin.js'
  95. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  96. import Popu from '@/components/template/popu.vue'
  97. import { getToken } from '@/utils/auth'
  98. import { getListV2, getDownloadList, deleteData, exportFile, handleImport } from '@/api/issue'
  99. import FileUpload from '@/components/Common/file-upload.vue'
  100. export default {
  101. components: { TemplatePage, Popu, FileUpload },
  102. mixins: [import_mixin, add_callback_mixin],
  103. data() {
  104. return {
  105. visible: false,
  106. // 事件组合
  107. optionsEvensGroup: [
  108. [
  109. [
  110. {
  111. name: '新增',
  112. click: this.addOn(() => {
  113. this.clickImport()
  114. }),
  115. isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  116. }
  117. ]
  118. ]
  119. ],
  120. // 表格属性
  121. tableAttributes: {
  122. // 启用勾选列
  123. selectColumn: true
  124. }, // 关闭新增弹窗
  125. // 表格事件
  126. tableEvents: {
  127. 'selection-change': this.selectionChange
  128. },
  129. recordSelected: [],
  130. imageURL: this.$imageUrl,
  131. dataList: null, // 列表数据
  132. listLoading: true, // 列表加载loading
  133. currentPage: 1, // 当前页码
  134. pageSize: 10, // 每页数量
  135. listTotal: 0, // 列表总数
  136. screenForm: {
  137. // 筛选表单数据
  138. title: ''
  139. },
  140. importForm: {
  141. title: '',
  142. remark: ''
  143. },
  144. importFormDialog: false,
  145. fileList: [],
  146. isCollapse: true,
  147. detailDialog: false, // 详情 - 弹窗
  148. detailTable_dataList: null, // 详情 - 列表数据
  149. detailTable_listLoading: true, // 详情 - 列表加载loading
  150. detailTable_currentPage: 1, // 详情 - 当前页码
  151. detailTable_pageSize: 10, // 详情 - 每页数量
  152. detailTable_listTotal: 0 // 详情 - 列表总数
  153. }
  154. },
  155. methods: {
  156. // 列表请求函数
  157. getList(...p) {
  158. this.recordSelected = []
  159. return getListV2(...p)
  160. },
  161. // 列表导出函数
  162. exportList: () => {},
  163. // 表格列解析渲染数据更改
  164. columnParsing(item, defaultData) {
  165. return defaultData
  166. },
  167. // 监听勾选变化
  168. selectionChange(data) {
  169. this.recordSelected = data
  170. },
  171. operation() {
  172. return (h, { row, index, column }) => {
  173. return (
  174. <div class="operation-btns">
  175. {this.checkBtnRole('edit') ? (
  176. <el-button
  177. size="mini"
  178. type="text"
  179. onClick={() => {
  180. this.openDetail(row.id)
  181. }}
  182. >
  183. 详情
  184. </el-button>
  185. ) : null}
  186. {this.checkBtnRole('edit') ? (
  187. <el-button
  188. size="mini"
  189. type="text"
  190. onClick={() => {
  191. this.handleExport(row)
  192. }}
  193. >
  194. 下载
  195. </el-button>
  196. ) : null}
  197. {
  198. <el-popconfirm
  199. title="确定删除吗?"
  200. onOnConfirm={() => this.deleteData(row.id)}
  201. >
  202. <el-button slot="reference" type="text" size="mini">
  203. 删除
  204. </el-button>
  205. </el-popconfirm>
  206. }
  207. </div>
  208. )
  209. }
  210. },
  211. handleClose() {
  212. this.addOff(() => {
  213. this.visible = false
  214. })()
  215. },
  216. // 查询按钮权限
  217. checkBtnRole(value) {
  218. return true
  219. let btnRole = this.$route.meta.roles
  220. if (!btnRole) {
  221. return true
  222. }
  223. let index = btnRole.indexOf(value)
  224. return index >= 0 ? true : false
  225. },
  226. // 操作 - 删除
  227. deleteData(id) {
  228. deleteData({ id }).then(res => {
  229. this.getList()
  230. this.$successMsg()
  231. })
  232. },
  233. // 详情 - 获取列表
  234. getDownloadList() {
  235. getDownloadList({
  236. pageNo: this.detailTable_currentPage,
  237. pageSize: this.detailTable_pageSize,
  238. id: this.detailId
  239. }).then(res => {
  240. this.detailTable_dataList = res.data.records
  241. this.detailTable_listTotal = res.data.total
  242. this.detailTable_listLoading = false
  243. })
  244. },
  245. // 详情 - 打开弹窗
  246. openDetail(id) {
  247. this.detailId = id
  248. this.detailDialog = true
  249. this.detailTable_currentPage = 1
  250. this.getDownloadList()
  251. },
  252. // 详情 - 更改列表当前页
  253. detailTableCurrentChange(val) {
  254. this.detailTable_currentPage = val
  255. this.getDownloadList()
  256. },
  257. // 点击导入
  258. clickImport() {
  259. this.importFormDialog = true
  260. },
  261. // 取消 导入
  262. cancelImportForm() {
  263. this.addOff(() => {
  264. this.importFormDialog = false
  265. })()
  266. this.fileList = []
  267. this.importForm.title = ''
  268. this.importForm.remark = ''
  269. },
  270. // 导入
  271. async submitImportForm() {
  272. if (!this.importForm.title) {
  273. return this.$errorMsg('请填写标题')
  274. }
  275. if (this.fileList.length <= 0) {
  276. return this.$errorMsg('请上传文件')
  277. }
  278. const loading = this.$loading({
  279. lock: true,
  280. text: 'Loading',
  281. spinner: 'el-icon-loading',
  282. background: 'rgba(0, 0, 0, 0.7)'
  283. })
  284. const formData = {
  285. file: this.fileList[0].url,
  286. title: this.importForm.title,
  287. remark: this.importForm.remark
  288. }
  289. handleImport(formData)
  290. .then(res => {
  291. this.fileList = []
  292. this.getList()
  293. this.importFormDialog = false
  294. })
  295. .catch(res => {
  296. this.$errorMsg(res.message)
  297. })
  298. .finally(res => {
  299. loading.close()
  300. })
  301. },
  302. // 下载
  303. handleExport(item) {
  304. exportFile({ id: item.id }).then(res => {
  305. if (res.data) {
  306. window.open(this.imageURL + res.data)
  307. }
  308. })
  309. }
  310. }
  311. }
  312. </script>
  313. <style lang="scss" scoped>
  314. .tips {
  315. font-size: 14px;
  316. color: red;
  317. line-height: 32px;
  318. margin-left: 10px;
  319. }
  320. </style>