list.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div>
  3. <FullPage title='超标价格方案'
  4. :list='list'
  5. @init='init'
  6. :loading='loading'
  7. @searchData='searchData'
  8. @changePage='changePage'
  9. @changeSize='changeSize'
  10. :tableColums='tableColums'
  11. :tableData='tableData'
  12. :page_index='page_index'
  13. :total='total'>
  14. <div slot='titleButton'>
  15. <Button @click="exportData()" type="primary" style="margin-right: 10px">批量导出</Button>
  16. <Button @click="handleSet('',-1,1)"
  17. type='primary'
  18. style="margin-right:10px;">新增方案</Button>
  19. </div>
  20. <template slot='set'
  21. slot-scope='{row,index}'>
  22. <div class="table-set">
  23. <a style="margin:0 5px"
  24. @click="handleSet(row,index,2)">编辑</a>
  25. <a style="margin:0 5px"
  26. @click="handleSet(row,index,3)">查看</a>
  27. <a style="margin:0 5px"
  28. @click="handleSet(row,index,4)">删除</a>
  29. </div>
  30. </template>
  31. </FullPage>
  32. </div>
  33. </template>
  34. <script>
  35. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  36. // 例如:import 《组件名称》 from '《组件路径》';
  37. export default {
  38. name: 'OverStandardPriceList',
  39. components: {
  40. },
  41. props: {},
  42. // import引入的组件需要注入到对象中才能使用
  43. data () {
  44. // 这里存放数据
  45. return {
  46. list: [
  47. { title: '方案名称', name: 'Input', value: '', serverName: 'title', placeholder: '请输入方案名称' },
  48. ],
  49. loading: false,
  50. tableData: [],
  51. page_index: 1,
  52. total: 0,
  53. page_size: 10,
  54. proxyObj: {},
  55. tableColums: [
  56. { title: '序号', type: 'index', key: '', align: 'center', width: 80 },
  57. { title: '方案名称', key: 'title', align: 'center', tooltip: true, minWidth: 140 },
  58. { title: '操作', key: '', align: 'center', slot: 'set', width: 200 },
  59. ],
  60. tableData: [],
  61. }
  62. },
  63. // 生命周期 - 创建完成(可以访问当前this实例)
  64. created () {
  65. },
  66. // 生命周期 - 挂载完成(可以访问DOM元素)
  67. mounted () {
  68. },
  69. methods: {
  70. async exportData(){
  71. const res = await this.axios('/api/overdraft_export')
  72. if(res.code == 200){
  73. let url = `${this.$store.state.ip}/api/storage/${res.data.file}`
  74. location.href = url
  75. }
  76. },
  77. init (row) {
  78. this.proxyObj = row
  79. this.axios.get('/api/overdraft_list', {
  80. params: {
  81. page_index: this.page_index,
  82. page_size: this.page_size,
  83. ...row
  84. }
  85. }).then(res => {
  86. console.log(res)
  87. if (res.code == 200) {
  88. this.total = res.data.total
  89. this.tableData = res.data.data
  90. }
  91. }).catch(err => { console.error(err); })
  92. },
  93. searchData (row) {
  94. this.proxyObj = row
  95. this.page_index = 1;
  96. this.init(this.proxyObj)
  97. },
  98. handleSet (row, index, type) {
  99. // 1新增 2编辑 3查看 4删除
  100. switch (type) {
  101. case 1:
  102. case 2:
  103. case 3:
  104. this.$router.push({
  105. path: '/cms/BasicSettings/OverStandardPrice/detail',
  106. query: {
  107. type,
  108. id: row.id,
  109. }
  110. })
  111. break;
  112. case 4:
  113. this.$Modal.confirm({
  114. title: '确认删除?',
  115. content: '此操作无法恢复,请确认!',
  116. onOk: () => {
  117. this.axios({
  118. method: 'post',
  119. url: '/api/overdraft_del',
  120. data: {
  121. id: row.id
  122. }
  123. }).then((res) => {
  124. this.$Message.success(res.msg)
  125. this.init(this.proxyObj)
  126. }).catch((err) => { });
  127. },
  128. onCancel: () => { }
  129. })
  130. break;
  131. default:
  132. break;
  133. }
  134. },
  135. changePage (e) {
  136. this.page_index = e;
  137. this.init(this.proxyObj)
  138. },
  139. changeSize (e) {
  140. this.page_size = e;
  141. this.init(this.proxyObj)
  142. },
  143. },
  144. // 监听属性 类似于data概念
  145. computed: {},
  146. // 监控data中的数据变化
  147. watch: {},
  148. beforeCreate () { }, // 生命周期 - 创建之前
  149. beforeMount () { }, // 生命周期 - 挂载之前
  150. beforeUpdate () { }, // 生命周期 - 更新之前
  151. updated () { }, // 生命周期 - 更新之后
  152. beforeDestroy () { }, // 生命周期 - 销毁之前
  153. destroyed () { }, // 生命周期 - 销毁完成
  154. activated () { }, // 如果页面有keep-alive缓存功能,这个函数会触发
  155. }
  156. </script>
  157. <style lang='scss' scoped>
  158. </style>