index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="view-dataSailingMaterialMaterialCoding">
  3. <div class="view-dataSailingMaterialMaterialCoding-left">
  4. <MenuTree :currentNodeKey="currentNodeValue" :nodeKey="nodeKey" :treedata="menuTreeData" @TreeNodeclick="treeNodeClick" v-bind="treeObj"> </MenuTree>
  5. </div>
  6. <div class="view-dataSailingMaterialMaterialCoding-right">
  7. <div class="common-box">
  8. <div class="common-box-button">
  9. <el-button type="success" @click="handleAdd" :disabled="currentNodeValue == ''">新增</el-button>
  10. <el-button
  11. type="warning"
  12. @click="
  13. confirmation(
  14. {
  15. msg: '确认删除当前选中项?'
  16. },
  17. () => tableDelete(tableCheckItems)
  18. )
  19. "
  20. :disabled="tableCheckItems.length == 0"
  21. >删除</el-button
  22. >
  23. <el-button type="primary" @click="selfMotionMapCode">自动映射编码</el-button>
  24. <el-dropdown split-button type="primary" style="margin-left: 10px" trigger="click" @command="handleExportBtn">
  25. 更多
  26. <el-dropdown-menu slot="dropdown">
  27. <el-dropdown-item command="importOperation">导入</el-dropdown-item>
  28. <el-dropdown-item command="allExport" :disabled="tableData.length == 0">导出</el-dropdown-item>
  29. <el-dropdown-item command="downloadTemplate">下载数据模板</el-dropdown-item>
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. </div>
  33. <div class="common-box-select"></div>
  34. <div class="common-box-search">
  35. <el-input placeholder="航材编码/名称/规格型号" v-model="searchValue" class="input-with-select">
  36. <el-button slot="append" icon="el-icon-search"></el-button>
  37. </el-input>
  38. </div>
  39. </div>
  40. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :columns="columns" :dataSource="tableData" :options="options" :fetch="fetchTableData" :pagination="tableRequset"></LTable>
  41. <!-- -->
  42. <CrudDialog v-bind="modalConfig" ref="NewDialogRef" @crudDialogSubmit="crudDialogSubmit"></CrudDialog>
  43. <!-- 导入 -->
  44. <ImportDialog ref="ImportDialog" @submitCallBack="ImportDialogCallBack" />
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import { MessageBox } from 'element-ui' //这里是引入 element
  50. import { defaultProps, columns, options, modalConfig } from './index'
  51. import { debounce } from '@/utils/index'
  52. import { getAvmatCategoriesTree, getAvmatCatalog, queryByCodeOrName } from '@/api/basicData/dataSpecies'
  53. import { addAvmatCatalog, editAvmatCatalog, removeAvmatCatalog, downLoadFile, exportExcel } from '@/api/basicData/dataSailingMaterialMaterialCoding'
  54. import ImportDialog from './importDialog/index.vue'
  55. import { autoMapping } from '@/api/task/carrierFlightMission'
  56. import Vue from 'vue'
  57. export default {
  58. name: 'dataSailingMaterialMaterialCoding',
  59. components: { ImportDialog },
  60. data() {
  61. // 这里存放数据
  62. return {
  63. nodeKey: 'avmatCategoriesId',
  64. currentNodeValue: '',
  65. currentNode: null,
  66. menuTreeData: [],
  67. treeObj: {
  68. title: '所属分类',
  69. activityheight: '275px',
  70. searchIcon: false,
  71. configure: defaultProps
  72. },
  73. options,
  74. columns: columns(this),
  75. modalConfig: modalConfig(this),
  76. tableData: [],
  77. defaultcheCkedKeys: ['1'],
  78. searchValue: '',
  79. debounceFn: debounce(this.fetchTableData2, 500),
  80. tableRequset: {
  81. total: 0,
  82. pageIndex: 1,
  83. pageSize: 20
  84. },
  85. tableCheckItems: [],
  86. removeArr: []
  87. }
  88. },
  89. mounted() {
  90. this.getData()
  91. },
  92. watch: {
  93. searchValue: function () {
  94. this.debounceFn()
  95. }
  96. },
  97. methods: {
  98. async getData() {
  99. const { data } = await getAvmatCategoriesTree()
  100. let obj = {
  101. avmatCategoriesId: '',
  102. avmatCategoriesCode: '',
  103. avmatCategoriesName: '全部',
  104. children: data
  105. }
  106. this.menuTreeData = [obj]
  107. this.currentNodeValue = ''
  108. this.fetchTableData()
  109. },
  110. treeNodeClick(node) {
  111. this.searchValue = ''
  112. this.currentNodeValue = node[this.nodeKey]
  113. this.currentNode = node
  114. this.fetchTableData()
  115. },
  116. async fetchTableData() {
  117. this.$refs.table.clearSelection()
  118. let params = {
  119. pageSize: this.tableRequset.pageSize,
  120. pageIndex: this.tableRequset.pageIndex,
  121. avmatCategoriesId: this.currentNodeValue,
  122. avmatType: 1
  123. }
  124. const { data } = await getAvmatCatalog(params)
  125. this.tableData = data.list
  126. this.tableRequset.total = data.totalCount
  127. },
  128. async fetchTableData2() {
  129. let params = {
  130. pageSize: this.tableRequset.pageSize,
  131. pageIndex: 1,
  132. queryParam: this.searchValue,
  133. avmatType: 1
  134. }
  135. this.currentNodeValue = ''
  136. const { data } = await queryByCodeOrName(params)
  137. this.tableData = data.list
  138. this.tableRequset.total = data.totalCount
  139. },
  140. // 单选
  141. selection(val) {
  142. this.tableCheckItems = val
  143. },
  144. handleExport(type) {
  145. let msg = ''
  146. type == '下载模板' ? (msg = '是否确认下载该模板') : (msg = `是否${type}该航材`)
  147. this.$confirm(msg, '提示', {
  148. confirmButtonText: '确定',
  149. cancelButtonText: '取消',
  150. type: 'warning'
  151. })
  152. .then(() => {
  153. this.$message({
  154. type: 'success',
  155. message: '操作成功!'
  156. })
  157. })
  158. .catch(() => {})
  159. },
  160. getClassification(node) {
  161. let { classificationName } = node
  162. Vue.set(this.$refs.NewDialogRef.formData, 'classificationName', classificationName)
  163. this.$refs.NewDialogRef.$refs.onTreeSelect && this.$refs.NewDialogRef?.$refs.onTreeSelect[0].blur()
  164. },
  165. confirmation(params, fun) {
  166. const { msg = '', title = '提示', confirmButtonText = '确定', cancelButtonText = '取消' } = params
  167. MessageBox.confirm(msg, title, {
  168. confirmButtonText: confirmButtonText,
  169. cancelButtonText: cancelButtonText,
  170. type: 'warning'
  171. })
  172. .then(() => {
  173. fun()
  174. })
  175. .catch(() => {})
  176. },
  177. handleAdd() {
  178. let config = {
  179. type: 'add',
  180. dataShow: {
  181. isRepairable: 1,
  182. isCompleteSet: 1,
  183. isOrdered: 1,
  184. isImported: 1,
  185. ...(this.currentNode ? { avmatCategoriesName: this.currentNode.avmatCategoriesName } : {})
  186. },
  187. title: '新增'
  188. }
  189. this.$refs.NewDialogRef.open(config)
  190. },
  191. handUpdate(row) {
  192. let config = {
  193. type: 'update',
  194. dataShow: row, // 回填的值(字段对应上)
  195. title: '编辑'
  196. }
  197. this.$refs.NewDialogRef.open(config)
  198. },
  199. async tableDelete(params) {
  200. const { success } = await removeAvmatCatalog(params.map((e) => e.avmatCatalogId))
  201. if (success) {
  202. this.$message({
  203. type: 'success',
  204. message: '操作成功!'
  205. })
  206. this.fetchTableData()
  207. }
  208. },
  209. async add(params) {
  210. try {
  211. const { success } = await addAvmatCatalog({ avmatType: 1, avmatCategoriesId: this.currentNodeValue, ...params })
  212. if (success) {
  213. this.$message({
  214. type: 'success',
  215. message: '操作成功!'
  216. })
  217. this.fetchTableData()
  218. }
  219. } catch (error) {}
  220. },
  221. async update(params) {
  222. try {
  223. const { success } = await editAvmatCatalog({ avmatType: 1, avmatCategoriesId: this.currentNodeValue, ...params })
  224. if (success) {
  225. this.$message({
  226. type: 'success',
  227. message: '操作成功!'
  228. })
  229. this.fetchTableData()
  230. }
  231. } catch (error) {}
  232. },
  233. crudDialogSubmit(data) {
  234. const { dialogData, type } = data
  235. switch (type) {
  236. case 'add':
  237. this.add(dialogData)
  238. break
  239. case 'update':
  240. this.update(dialogData)
  241. break
  242. }
  243. },
  244. selfMotionMapCode() {
  245. this.$confirm('是否自动映射所有编码', '提示', {
  246. confirmButtonText: '确定',
  247. cancelButtonText: '取消',
  248. type: 'warning'
  249. })
  250. .then(async () => {
  251. const { code, data } = await autoMapping()
  252. if (code == 200) {
  253. this.fetchTableData()
  254. useMessage('success', '映射成功', 1000)
  255. }
  256. })
  257. .catch(() => {})
  258. },
  259. //更多按钮
  260. handleExportBtn(type) {
  261. this[type]()
  262. },
  263. //导入
  264. importOperation() {
  265. this.$refs.ImportDialog.triggerDialog()
  266. },
  267. //导入回写
  268. ImportDialogCallBack() {
  269. this.fetchTableData()
  270. },
  271. //导出全部
  272. async allExport() {
  273. const userInfo = this.$store.state.user.userInfo.user
  274. const params = {
  275. queryParam: this.queryParam,
  276. avmatCategoriesId: this.currentNodeValue,
  277. userId: userInfo.userId,
  278. avmatType: 1
  279. }
  280. await exportExcel(params)
  281. },
  282. //下载模板
  283. async downloadTemplate() {
  284. const params = {
  285. avmatType: 1
  286. }
  287. await downLoadFile(params)
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="scss">
  293. @import './index.scss';
  294. </style>