index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div class="view-table-content">
  3. <div style="width: 100%">
  4. <div class="view-dataType-title">
  5. <div class="view-dataType-title-btn">
  6. <el-button type="success" @click="openDialog()">上传文件</el-button>
  7. <el-button type="warning" @click="remove(tableCheckItems)" :disabled="tableCheckItems.length == 0">删除</el-button>
  8. </div>
  9. <div class="view-dataType-title-search">
  10. <el-input placeholder="请输入文件名称" v-model="keyWordData" class="input1">
  11. <el-button slot="append" icon="el-icon-search" @click="searchClick"></el-button>
  12. </el-input>
  13. </div>
  14. </div>
  15. <div class="view-dataType-table">
  16. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequset"></LTable>
  17. </div>
  18. <!-- 添加或修改模型信息对话框 -->
  19. <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
  20. <el-form ref="form" :model="form" label-width="80px">
  21. <el-form-item label="文件名称" prop="fileName">
  22. <el-input v-model="form.fileName" placeholder="请输入文件名称" />
  23. </el-form-item>
  24. <el-form-item label="文件类型" prop="fileType">
  25. <el-select v-model="form.fileType" placeholder="请选择文件类型">
  26. <el-option v-for="item in fileTypeList" :key="item.key" :label="item.name" :value="item.key" />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="选择文件" prop="ossId">
  30. <FileUpload v-model="form.ossId" :limit="1" :fileSize="500" :fileType="['docx', 'doc', 'pdf']" />
  31. </el-form-item>
  32. <el-form-item label="备注" prop="remarks">
  33. <el-input type="textarea" :rows="2" v-model="form.remarks" placeholder="请输入备注" />
  34. </el-form-item>
  35. </el-form>
  36. <span slot="footer" class="dialog-footer">
  37. <el-button @click="handleClose">取 消</el-button>
  38. <el-button type="primary" @click="submit">确 定</el-button>
  39. </span>
  40. </el-dialog>
  41. </div>
  42. </div>
  43. </template>
  44. <script>
  45. import { getAtlasFile, addAtlasFile, updateAtlasFile, removeAtlasFile } from '@/api/als/atlasFile'
  46. import { deepClone, debounce } from '@/utils/index'
  47. import FileUpload from '@/views/als/components/FileUpload'
  48. export default {
  49. name: 'AtlasFile',
  50. components: { FileUpload },
  51. data() {
  52. // 这里存放数据
  53. return {
  54. dialogTitle: '新增',
  55. dialogVisible: false,
  56. keyWordData: '',
  57. searchValue: '',
  58. columns: [
  59. {
  60. prop: 'fileName',
  61. label: '文件名称'
  62. },
  63. {
  64. prop: 'fileType',
  65. label: '文件类型'
  66. },
  67. {
  68. prop: 'ossId',
  69. label: '文件编号'
  70. },
  71. {
  72. prop: 'remarks',
  73. label: '备注'
  74. },
  75. {
  76. button: true,
  77. label: '操作',
  78. width: '240px',
  79. group: [
  80. {
  81. name: '编辑',
  82. type: 'text',
  83. round: false,
  84. plain: false,
  85. onClick: (row, index, scope) => {
  86. this.handUpdate(row)
  87. }
  88. },
  89. {
  90. name: '删除',
  91. type: 'text',
  92. round: false,
  93. plain: false,
  94. onClick: (row, index, scope) => {
  95. this.remove([row])
  96. }
  97. }
  98. ]
  99. }
  100. ],
  101. options: {
  102. stripe: false, // 斑马纹
  103. mutiSelect: true, // 多选框
  104. index: false, // 显示序号, 多选则 mutiSelect
  105. loading: false, // 表格动画
  106. initTable: false, // 是否一挂载就加载数据
  107. border: true,
  108. height: 'calc(100vh - 300px)'
  109. },
  110. tableCheckItems: [],
  111. tableData: [],
  112. tableRequset: {
  113. total: 0,
  114. pageIndex: 1,
  115. pageSize: 20,
  116. searchValue: ''
  117. },
  118. form: {
  119. id: '',
  120. fileName: '',
  121. fileType: '',
  122. ossId: '',
  123. status: '',
  124. remarks: ''
  125. },
  126. debounceFn: debounce(this.fetch, 500),
  127. fileTypeList: [
  128. { key: '术语', name: '术语' },
  129. { key: '故障案例', name: '故障案例' },
  130. { key: '专业手册', name: '专业手册' },
  131. { key: '期刊', name: '期刊' },
  132. { key: '其它', name: '其它' }
  133. ]
  134. }
  135. },
  136. watch: {
  137. keyWord() {
  138. this.tableRequset.pageIndex = 1
  139. this.debounceFn()
  140. }
  141. },
  142. mounted() {
  143. this.getAtlasFileAPI()
  144. },
  145. methods: {
  146. async removeAtlasFileAPI(params) {
  147. try {
  148. const { code } = await removeAtlasFile(params)
  149. if (code === 200) {
  150. this.$message({
  151. type: 'success',
  152. message: '操作成功!'
  153. })
  154. await this.getAtlasFileAPI()
  155. this.handleClose()
  156. }
  157. } catch (error) {}
  158. },
  159. async getAtlasFileAPI(params) {
  160. if (this.$refs.table) this.$refs.table.clearSelection()
  161. const { pageSize, pageIndex } = this.tableRequset
  162. const {
  163. data: { list, total }
  164. } = await getAtlasFile({ pageSize, pageNum: pageIndex, ...params })
  165. this.tableData = list
  166. this.tableRequset.total = total
  167. },
  168. fetch() {
  169. this.getAtlasFileAPI()
  170. },
  171. async searchClick() {
  172. this.getAtlasFileAPI({ fileName: this.keyWordData })
  173. },
  174. async addAtlasFileAPI() {
  175. try {
  176. delete this.form.aircaftModelName
  177. const { code } = await addAtlasFile({ ...this.form })
  178. if (code === 200) {
  179. this.$message({
  180. type: 'success',
  181. message: '操作成功!'
  182. })
  183. this.handleClose()
  184. this.getAtlasFileAPI()
  185. }
  186. } catch (error) {}
  187. },
  188. async updateAtlasFileAPI() {
  189. try {
  190. const { code } = await updateAtlasFile({ ...this.form })
  191. if (code === 200) {
  192. this.$message({
  193. type: 'success',
  194. message: '操作成功!'
  195. })
  196. this.handleClose()
  197. this.getAtlasFileAPI()
  198. }
  199. } catch (error) {}
  200. },
  201. openDialog() {
  202. this.dialogTitle = '新增'
  203. this.dialogVisible = true
  204. },
  205. handleClose() {
  206. this.dialogVisible = false
  207. this.form = {
  208. id: '',
  209. fileName: '',
  210. fileType: '',
  211. ossId: '',
  212. status: '',
  213. remarks: ''
  214. }
  215. },
  216. handUpdate(row) {
  217. this.dialogTitle = '编辑'
  218. this.form = deepClone(row)
  219. this.dialogVisible = true
  220. },
  221. submit() {
  222. switch (this.dialogTitle) {
  223. case '编辑':
  224. this.updateAtlasFileAPI()
  225. break
  226. case '新增':
  227. this.addAtlasFileAPI()
  228. break
  229. }
  230. },
  231. selection(val) {
  232. this.tableCheckItems = val
  233. },
  234. remove(row) {
  235. this.$confirm('是否删除该模型', '提示', {
  236. confirmButtonText: '确定',
  237. cancelButtonText: '取消',
  238. type: 'warning'
  239. })
  240. .then(() => {
  241. this.removeAtlasFileAPI(row.map((e) => e.id))
  242. })
  243. .catch(() => {})
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="scss" scoped>
  249. @import '../index.scss';
  250. </style>