index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <div>
  3. <el-breadcrumb class="heading">
  4. <el-breadcrumb-item :to="{ path: '/' }">平台首页</el-breadcrumb-item>
  5. <el-breadcrumb-item :to="{ path: '/oilsupplier/goodsaptitude' }">物资类项目与资质对照表</el-breadcrumb-item>
  6. </el-breadcrumb>
  7. <el-card class="box-card"
  8. style="height: calc(100vh - 115px);" v-loading="loading">
  9. <div slot="header">
  10. <span>
  11. <i class="icon icon-table2"></i> 物资类项目与资质对照表
  12. </span>
  13. <el-form ref="form"
  14. :inline="true"
  15. style="float: right; margin-top: -10px">
  16. <el-form-item label="编码">
  17. <el-input size="mini"
  18. v-model="Code"
  19. style="width:100%"
  20. placeholder="请输入"></el-input>
  21. </el-form-item>
  22. <el-form-item label="名称">
  23. <el-input size="mini"
  24. v-model="Name"
  25. style="width:100%"
  26. placeholder="请输入"></el-input>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-dropdown split-button
  30. type="primary"
  31. size="mini"
  32. @click="initDatas"
  33. @command="searchCommand">
  34. 查询
  35. <el-dropdown-menu slot="dropdown">
  36. <el-dropdown-item command="clear">查询重置</el-dropdown-item>
  37. </el-dropdown-menu>
  38. </el-dropdown>
  39. <router-link :to="'/oilsupplier/goodsaptitude2019/add/operation'">
  40. <el-button type="primary"
  41. size="mini"
  42. style="margin-left:10px; margin-top: -4px;">添加</el-button>
  43. </router-link>
  44. <el-button type="primary"
  45. size="mini"
  46. style="margin-left:10px; margin-top: -4px;"
  47. @click="exportExcel">导出
  48. </el-button>
  49. </el-form-item>
  50. </el-form>
  51. </div>
  52. <el-table id="rebateSetTable"
  53. :data="entityList"
  54. size="mini"
  55. border
  56. height="calc(100vh - 243px)"
  57. style="width: 100%"
  58. @sort-change="orderby">
  59. <el-table-column label="操作"
  60. min-width="200"
  61. align="center"
  62. fixed="right">
  63. <template slot-scope="scope">
  64. <router-link :to="'/oilsupplier/goodsaptitude2019/' + scope.row.Id + '/operation'">
  65. <el-button type="primary"
  66. plain
  67. title="编辑"
  68. size="mini">编辑</el-button>
  69. </router-link>
  70. </template>
  71. </el-table-column>
  72. <el-table-column v-for="column in tableColumns"
  73. :prop="column.prop"
  74. sortable
  75. :width="column.width"
  76. :key="column.Id"
  77. :label="column.label"
  78. align="center"
  79. show-overflow-tooltip>
  80. </el-table-column>
  81. <!--动态显示的表头-->
  82. <el-table-column v-for="column in dynamicTableColumns"
  83. :prop="column.prop"
  84. sortable
  85. :width="320"
  86. :key="column.Id"
  87. :label="column.label"
  88. align="center"
  89. show-overflow-tooltip>
  90. <template slot-scope="scope">
  91. {{ transferStr(scope.row[column.prop]) }}
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. <el-pagination @size-change="handleSizeChange"
  96. @current-change="handleCurrentChange"
  97. :current-page="currentPage"
  98. :page-sizes="[10, 50, 100, 200, 400]"
  99. :page-size="size"
  100. layout="total, sizes, prev, pager, next, jumper"
  101. :total="currentItemCount">
  102. </el-pagination>
  103. </el-card>
  104. </div>
  105. </template>
  106. <script>
  107. import {
  108. mapGetters
  109. } from 'vuex'
  110. import api from '@/api/oilsupplier/goodsaptitude'
  111. import setapi from '@/api/oilsupplier/oilclassorgset'
  112. import FileSaver from 'file-saver'
  113. import XLSX from 'xlsx'
  114. export default {
  115. computed: {
  116. ...mapGetters({
  117. authUser: 'authUser'
  118. })
  119. },
  120. name: 'oilgoodsaptitude2019',
  121. data () {
  122. return {
  123. loading: false,
  124. Code: '',
  125. Name: '',
  126. // 列表数据
  127. entityList: [],
  128. // 分页参数
  129. size: 10,
  130. currentPage: 1,
  131. currentItemCount: 0,
  132. // 列表排序
  133. Column: {
  134. Order: '',
  135. Prop: ''
  136. },
  137. tableColumns: [
  138. {
  139. prop: 'Code',
  140. label: '编码',
  141. width: 120,
  142. sort: true
  143. },
  144. {
  145. prop: 'Name',
  146. label: '名称',
  147. width: 150,
  148. sort: true
  149. },
  150. {
  151. prop: 'GoodsLevel',
  152. label: '物资级别',
  153. width: 110,
  154. sort: true
  155. },
  156. {
  157. prop: 'GoodsDesc',
  158. label: '产品说明',
  159. width: 110,
  160. sort: true
  161. },
  162. {
  163. prop: 'Standard',
  164. label: '标准备案',
  165. width: 110,
  166. sort: true
  167. },
  168. {
  169. prop: 'CompanyType',
  170. label: '供应商类型',
  171. width: 130,
  172. sort: true
  173. }
  174. ],
  175. dynamicTableColumns: []
  176. }
  177. },
  178. created () {
  179. this.initTableHeader()
  180. // 查询列表
  181. this.initDatas()
  182. },
  183. methods: {
  184. searchCommand (command) {
  185. if (command === 'search') {
  186. this.dialogVisible = true
  187. } else if (command === 'clear') {
  188. this.clearSearch()
  189. }
  190. },
  191. clearSearch () {
  192. this.size = 10
  193. this.currentPage = 1
  194. this.currentItemCount = 0
  195. this.Name = ''
  196. this.Code = ''
  197. this.initDatas()
  198. },
  199. // exportExcel () {
  200. // /* generate workbook object from table */
  201. // let table = document.querySelector('#rebateSetTable').cloneNode(true) // 克隆备份(原table不动)
  202. // // 因为element-ui的表格的fixed属性导致多出一个table,会下载重复内容,这里删除掉
  203. // table.removeChild(table.querySelector('.el-table__fixed-right')) // 删掉备份的子节点
  204. // let wb = XLSX.utils.table_to_book(table, {
  205. // raw: true
  206. // })
  207. // /* get binary string as output */
  208. // let wbout = XLSX.write(wb, {
  209. // bookType: 'xlsx',
  210. // bookSST: true,
  211. // type: 'array'
  212. // })
  213. // try {
  214. // FileSaver.saveAs(
  215. // new Blob([wbout], {
  216. // type: 'application/octet-stream'
  217. // }),
  218. // 'Goods.xlsx'
  219. // )
  220. // } catch (e) {
  221. // if (typeof console !== 'undefined') console.log(e, wbout)
  222. // }
  223. // return wbout
  224. // },
  225. exportExcel () {
  226. this.loading = true
  227. // 显示列
  228. let showcolumn = this.tableColumns.concat(this.dynamicTableColumns)
  229. let showcolumnarr = []
  230. let showcolumnnamearr = []
  231. for (var i = 0; i < showcolumn.length; i++) {
  232. showcolumnarr.push(showcolumn[i].label)
  233. showcolumnnamearr.push(showcolumn[i].prop.replace(/,/g, ','))
  234. }
  235. let params = {
  236. _currentPage: this.currentPage,
  237. _size: this.size,
  238. Order: this.Column.Order,
  239. Prop: this.Column.Prop,
  240. Edition: '2',
  241. showcolumnarr: showcolumnarr + '',
  242. showcolumnnamearr: showcolumnnamearr + ''
  243. }
  244. api.exportExcelAll2019(params, this.$axios).then(res => {
  245. this.loading = false
  246. window.location = 'http://' + res.data
  247. })
  248. },
  249. initTableHeader () {
  250. setapi.initGoodTableHeader(this.$axios).then(res => {
  251. this.dynamicTableColumns = res.data.items
  252. })
  253. },
  254. initDatas () {
  255. // 分页及列表条件
  256. let params = {
  257. _currentPage: this.currentPage,
  258. _size: this.size,
  259. Order: this.Column.Order,
  260. Prop: this.Column.Prop,
  261. Edition: '2',
  262. Code: this.Code,
  263. Name: this.Name
  264. }
  265. // 访问接口
  266. api.get2019List(params, this.$axios).then(res => {
  267. this.entityList = res.data.items
  268. this.currentItemCount = res.data.currentItemCount
  269. }).catch(err => {
  270. console.error(err)
  271. })
  272. },
  273. // 列表排序功能
  274. orderby (column) {
  275. if (column.order === 'ascending') {
  276. this.Column.Order = 'asc'
  277. } else if (column.order === 'descending') {
  278. this.Column.Order = 'desc'
  279. }
  280. this.Column.Prop = column.prop
  281. this.initDatas()
  282. },
  283. handleCurrentChange (value) {
  284. this.currentPage = value
  285. this.initDatas()
  286. },
  287. handleSizeChange (value) {
  288. this.size = value
  289. this.currentPage = 1
  290. this.initDatas()
  291. },
  292. transferStr (val) {
  293. if (val === '1') {
  294. return '是'
  295. }
  296. if (val === '0') {
  297. return ''
  298. } else {
  299. return val
  300. }
  301. },
  302. jstimehandle (val) {
  303. if (val === '') {
  304. return '----'
  305. } else if (val === '0001-01-01T08:00:00+08:00') {
  306. return '----'
  307. } else if (val === '5000-01-01T23:59:59+08:00') {
  308. return '永久'
  309. } else {
  310. val = val.replace('T', ' ')
  311. return val.substring(0, 10)
  312. }
  313. },
  314. formatDateTime (date) {
  315. var y = date.getFullYear()
  316. var m = date.getMonth() + 1
  317. m = m < 10 ? ('0' + m) : m
  318. var d = date.getDate()
  319. d = d < 10 ? ('0' + d) : d
  320. var h = date.getHours()
  321. var minute = date.getMinutes()
  322. minute = minute < 10 ? ('0' + minute) : minute
  323. return y + '-' + m + '-' + d + ' ' + h + ':' + minute
  324. }
  325. }
  326. }
  327. </script>
  328. <style>
  329. .el-col {
  330. margin-bottom: 5px;
  331. }
  332. </style>