issue.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. style="margin-left: 10px;font-size: 12px;"
  200. title="确定删除吗?"
  201. onOnConfirm={() => this.deleteData(row.id)}
  202. >
  203. <el-button slot="reference" type="text">
  204. 删除
  205. </el-button>
  206. </el-popconfirm>
  207. }
  208. </div>
  209. )
  210. }
  211. },
  212. handleClose() {
  213. this.addOff(() => {
  214. this.visible = false
  215. })()
  216. },
  217. // 查询按钮权限
  218. checkBtnRole(value) {
  219. return true
  220. let btnRole = this.$route.meta.roles
  221. if (!btnRole) {
  222. return true
  223. }
  224. let index = btnRole.indexOf(value)
  225. return index >= 0 ? true : false
  226. },
  227. // 操作 - 删除
  228. deleteData(id) {
  229. deleteData({ id }).then(res => {
  230. this.getList()
  231. this.$successMsg()
  232. })
  233. },
  234. // 详情 - 获取列表
  235. getDownloadList() {
  236. getDownloadList({
  237. pageNo: this.detailTable_currentPage,
  238. pageSize: this.detailTable_pageSize,
  239. id: this.detailId
  240. }).then(res => {
  241. this.detailTable_dataList = res.data.records
  242. this.detailTable_listTotal = res.data.total
  243. this.detailTable_listLoading = false
  244. })
  245. },
  246. // 详情 - 打开弹窗
  247. openDetail(id) {
  248. this.detailId = id
  249. this.detailDialog = true
  250. this.detailTable_currentPage = 1
  251. this.getDownloadList()
  252. },
  253. // 详情 - 更改列表当前页
  254. detailTableCurrentChange(val) {
  255. this.detailTable_currentPage = val
  256. this.getDownloadList()
  257. },
  258. // 点击导入
  259. clickImport() {
  260. this.importFormDialog = true
  261. },
  262. // 取消 导入
  263. cancelImportForm() {
  264. this.addOff(() => {
  265. this.importFormDialog = false
  266. })()
  267. this.fileList = []
  268. this.importForm.title = ''
  269. this.importForm.remark = ''
  270. },
  271. // 导入
  272. async submitImportForm() {
  273. if (!this.importForm.title) {
  274. return this.$errorMsg('请填写标题')
  275. }
  276. if (this.fileList.length <= 0) {
  277. return this.$errorMsg('请上传文件')
  278. }
  279. const loading = this.$loading({
  280. lock: true,
  281. text: 'Loading',
  282. spinner: 'el-icon-loading',
  283. background: 'rgba(0, 0, 0, 0.7)'
  284. })
  285. const formData = {
  286. file: this.fileList[0].url,
  287. title: this.importForm.title,
  288. remark: this.importForm.remark
  289. }
  290. handleImport(formData)
  291. .then(res => {
  292. this.fileList = []
  293. this.getList()
  294. this.importFormDialog = false
  295. })
  296. .catch(res => {
  297. this.$errorMsg(res.message)
  298. })
  299. .finally(res => {
  300. loading.close()
  301. })
  302. },
  303. // 下载
  304. handleExport(item) {
  305. exportFile({ id: item.id }).then(res => {
  306. if (res.data) {
  307. window.open(this.imageURL + res.data)
  308. }
  309. })
  310. }
  311. }
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. .tips {
  316. font-size: 14px;
  317. color: red;
  318. line-height: 32px;
  319. margin-left: 10px;
  320. }
  321. </style>