index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <div
  3. class="fileManagement_List"
  4. v-loading.fullscreen.lock="fullscreenLoading"
  5. >
  6. <div class="fileManagement_List_headerSelect">
  7. <div class="fileManagement-list-btn">
  8. <el-form style="display: inline" :model="form" ref="form" inline>
  9. <el-form-item
  10. class="header_top_form"
  11. label="分类名称:"
  12. prop="typeId"
  13. >
  14. <el-select
  15. clearable
  16. filterable
  17. size="small"
  18. placeholder="请选择"
  19. v-model="form.typeId"
  20. @visible-change="visbleChange"
  21. >
  22. <el-option
  23. v-for="(item, index) in classifyList"
  24. :key="index"
  25. :label="item.name"
  26. :value="item.typeId"
  27. >
  28. </el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item class="header_top_form" label="文件名称:" prop="name">
  32. <el-input
  33. clearable
  34. v-model.trim="form.name"
  35. placeholder="请输入"
  36. size="small"
  37. ></el-input>
  38. </el-form-item>
  39. <el-form-item class="header_top_form" label="状态:" prop="status">
  40. <el-select
  41. v-model="form.status"
  42. clearable
  43. size="small"
  44. placeholder="请选择"
  45. >
  46. <el-option
  47. v-for="item in options"
  48. :key="item.value"
  49. :label="item.label"
  50. :value="item.value"
  51. >
  52. </el-option>
  53. </el-select>
  54. </el-form-item>
  55. </el-form>
  56. <div style="margin-right: 23px">
  57. <el-button
  58. size="small"
  59. type="primary"
  60. style="width: 88px"
  61. @click="search"
  62. >查询</el-button
  63. >
  64. <el-button size="small" style="width: 88px" @click="resetForm('form')"
  65. >重置</el-button
  66. >
  67. </div>
  68. </div>
  69. <div style="text-align: right">
  70. <el-button
  71. size="small"
  72. style="width: 104px; margin-right: 23px"
  73. icon="iconfont icon-a-zu13"
  74. @click="addList"
  75. >新增</el-button
  76. >
  77. </div>
  78. </div>
  79. <div>
  80. <el-table
  81. :data="tableData"
  82. stripe
  83. ref="editTable"
  84. :header-cell-style="{ background: '#F7F7F7' }"
  85. :height="screenHeight"
  86. >
  87. <el-table-column
  88. label="分类名称"
  89. prop="typeName"
  90. align="center"
  91. show-overflow-tooltip
  92. ></el-table-column>
  93. <el-table-column
  94. label="文件名称"
  95. prop="name"
  96. align="center"
  97. show-overflow-tooltip
  98. ></el-table-column>
  99. <el-table-column
  100. label="链接地址"
  101. prop="linkUrl"
  102. align="center"
  103. min-width="180"
  104. ></el-table-column>
  105. <el-table-column
  106. label="禁用/启用"
  107. prop="status"
  108. align="center"
  109. >
  110. <template slot-scope="scope">
  111. <div>
  112. <div>
  113. <el-switch
  114. v-model="scope.row.status"
  115. active-color="#17A8FF"
  116. inactive-color="#AFAFAF"
  117. @change="statusChange($event, scope.row)"
  118. >
  119. </el-switch>
  120. </div>
  121. </div> </template
  122. ></el-table-column>
  123. <el-table-column
  124. label="创建人"
  125. prop="createUser"
  126. align="center"
  127. show-overflow-tooltip
  128. ></el-table-column>
  129. <el-table-column
  130. label="创建时间"
  131. prop="createTime"
  132. align="center"
  133. show-overflow-tooltip
  134. ></el-table-column>
  135. <el-table-column label="操作" width="140px" align="center">
  136. <template slot-scope="scope">
  137. <div>
  138. <el-button type="text" @click="history(scope.row)"
  139. >历史版本</el-button
  140. >
  141. <el-button type="text" @click="edit(scope.row)">编辑</el-button>
  142. </div>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. </div>
  147. <el-pagination
  148. @size-change="handleSizeChange"
  149. @current-change="handleCurrentChange"
  150. :current-page="form.pageNum"
  151. :page-sizes="[100, 200, 300, 400]"
  152. :page-size="form.pageSize"
  153. background
  154. layout="total,prev, pager, next,jumper"
  155. :total="form.total"
  156. >
  157. </el-pagination>
  158. <editDialog ref="editDialogRefs" />
  159. <detailDialog ref="detailDialogRefs" />
  160. </div>
  161. </template>
  162. <script>
  163. import editDialog from './edit'
  164. import detailDialog from './detail'
  165. import * as api from '@/api/api'
  166. export default {
  167. name: 'fileManagement',
  168. components: {
  169. editDialog,
  170. detailDialog
  171. },
  172. data() {
  173. return {
  174. fullscreenLoading: false,
  175. tableData: [],
  176. options: [
  177. { label: '启用', value: 1 },
  178. { label: '禁用', value: 0 }
  179. ],
  180. form: {
  181. pageNum: 1,
  182. pageSize: 10,
  183. total: 0,
  184. name: '',
  185. start: '',
  186. status: '',
  187. typeId: ''
  188. },
  189. classifyList: [],
  190. screenHeight: document.body.clientHeight - 320,
  191. tableDataheight: 0
  192. }
  193. },
  194. mounted() {
  195. this.screenHeight = document.body.clientHeight - 320
  196. window.onresize = () => {
  197. return (() => {
  198. this.screenHeight = document.body.clientHeight - 320
  199. })()
  200. }
  201. this.listDataInit()
  202. },
  203. methods: {
  204. /**
  205. * @method 重置
  206. * **/
  207. resetForm(formName) {
  208. this.$refs[formName].resetFields()
  209. this.search()
  210. },
  211. /**
  212. * @method 分类下拉列表
  213. * **/
  214. visbleChange(val) {
  215. if (val) {
  216. api.GET('/doc/type/dropListAll').then(data => {
  217. if (data.code == 0) {
  218. this.classifyList = data.data
  219. }
  220. })
  221. }
  222. },
  223. /**
  224. * @method 搜索
  225. * **/
  226. search() {
  227. if (sessionStorage.getItem('filemanage')) {
  228. this.form.pageNum = Number(sessionStorage.getItem('filemanage'))
  229. sessionStorage.removeItem('filemanage')
  230. } else {
  231. this.form.pageNum = 1
  232. }
  233. this.listDataInit()
  234. },
  235. /**
  236. * @method 列表数据
  237. * **/
  238. listDataInit() {
  239. this.tableData = []
  240. this.fullscreenLoading = true
  241. let code = {
  242. name: this.form.name,
  243. page: this.form.pageNum,
  244. pageSize: this.form.pageSize,
  245. start: this.form.start,
  246. status: this.form.status,
  247. typeId: this.form.typeId
  248. }
  249. api
  250. .POST('/doc/getDocList', code)
  251. .then(res => {
  252. if (res.code == 0) {
  253. this.tableData = res.data.list
  254. this.tableData.forEach(item => {
  255. item.status == 1 ? (item.status = true) : (item.status = false)
  256. })
  257. this.form.pageNum = res.data.currPage
  258. this.form.pageSize = res.data.pageSize
  259. this.form.total = res.data.totalCount
  260. this.fullscreenLoading = false
  261. this.$nextTick(() => {
  262. this.$refs.editTable.bodyWrapper.scrollTop = this.tableDataheight
  263. this.tableDataheight = 0
  264. })
  265. }
  266. })
  267. .catch(() => {
  268. this.fullscreenLoading = false
  269. })
  270. },
  271. /**
  272. * @method 条数分页
  273. * **/
  274. handleSizeChange(val) {
  275. this.form.pageNum = 1
  276. this.form.pageSize = val
  277. this.listDataInit()
  278. },
  279. /**
  280. * @method 分页
  281. * **/
  282. handleCurrentChange(val) {
  283. this.form.pageNum = val
  284. this.listDataInit()
  285. },
  286. /**
  287. * @method 新增
  288. * **/
  289. addList() {
  290. let code = {
  291. title: '文件新增',
  292. show: true
  293. }
  294. this.$refs.editDialogRefs.openClose(code)
  295. },
  296. // 编辑
  297. edit(val) {
  298. this.tableDataheight = this.$refs.editTable.bodyWrapper.scrollTop
  299. sessionStorage.setItem('filemanage', this.form.pageNum)
  300. let code = {
  301. title: '文件编辑',
  302. show: false,
  303. id: val.id
  304. }
  305. this.$refs.editDialogRefs.openClose(code)
  306. },
  307. // 历史版本
  308. history(val) {
  309. this.tableDataheight = this.$refs.editTable.bodyWrapper.scrollTop
  310. sessionStorage.setItem('filemanage', this.form.pageNum)
  311. const code = {
  312. id: val.id
  313. }
  314. this.$refs.detailDialogRefs.openClose(code)
  315. },
  316. /**
  317. * @method 状态修改
  318. * **/
  319. statusChange(val, item) {
  320. this.tableDataheight = this.$refs.editTable.bodyWrapper.scrollTop
  321. sessionStorage.setItem('filemanage', this.form.pageNum)
  322. val ? (val = 1) : (val = 0)
  323. let code = {
  324. id: item.id,
  325. status: val
  326. }
  327. api
  328. .PUT('/doc/updateSwitch', code)
  329. .then(data => {
  330. if (data.code == 0) {
  331. this.search()
  332. this.$message.success(data.message)
  333. }
  334. })
  335. .catch(() => {
  336. this.search()
  337. })
  338. }
  339. }
  340. }
  341. </script>
  342. <style lang="less">
  343. .fileManagement_List {
  344. .fileManagement_List_headerSelect {
  345. .fileManagement-list-btn {
  346. display: flex;
  347. justify-content: space-between;
  348. align-items: center;
  349. margin-bottom: 10px;
  350. .el-input__suffix {
  351. height: 32px;
  352. }
  353. }
  354. margin-bottom: 20px;
  355. .el-form-item {
  356. margin-bottom: 10px;
  357. margin-right: 60px;
  358. .el-input__inner {
  359. background: #f5f5f5;
  360. opacity: 1;
  361. border-radius: 17px;
  362. }
  363. }
  364. .icon-a-zu13 {
  365. font-size: 11px;
  366. margin-right: 5px;
  367. }
  368. }
  369. }
  370. </style>