You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

524 lines
15 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <div class="mod-config">
  3. <div>
  4. <span @click="favoriteFunction()">
  5. <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
  6. </span>
  7. </div>
  8. <el-form :inline="true">
  9. <el-form-item>
  10. <excelUpload v-on:excelUploadChild="excelUploadChild"></excelUpload>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button @click="batchOut" type="primary">{{ buttons.outList }}</el-button>
  14. <el-button @click="saveColumnList()" type="primary" v-show="showDefault">{{ buttons.defaultTable }}</el-button>
  15. <el-button @click="userSetting" type="primary">{{ buttons.settingTable }}</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-table
  19. :height="height"
  20. :data="dataList"
  21. border
  22. v-loading="dataListLoading"
  23. style="width: 100%;">
  24. <el-table-column
  25. v-for="(item,index) in columnList" :key="index"
  26. :sortable="item.columnSortable"
  27. :prop="item.columnProp"
  28. :header-align="item.headerAlign"
  29. :show-overflow-tooltip="item.showOverflowTooltip"
  30. :align="item.align"
  31. :fixed="item.fixed"
  32. :min-width="item.columnWidth"
  33. :label="item.columnLabel">
  34. <template slot-scope="scope">
  35. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  36. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  37. style="width: 100px; height: 80px"/></span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column
  41. fixed="right"
  42. header-align="center"
  43. align="center"
  44. width="150"
  45. :label="buttons.cz">
  46. <template slot-scope="scope">
  47. <a type="text" size="small" @click="deleteRoll(scope.row)" herf="#">{{ buttons.delete }}</a>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <!-- 设置列 -->
  52. <column v-if="visible" ref="column" @refreshData="getTableUserColumn"></column>
  53. </div>
  54. </template>
  55. <script>
  56. import excelUpload from "../common/excelUpload";
  57. import AddOrUpdate from './crollinfo-add-or-update'
  58. import {getCRollInfoList, batchRollUpdateStatus} from '@/api/crollinfo/crollinfo.js'
  59. import column from "../common/column";
  60. import search from "../common/search";
  61. import {
  62. searchSysLanguageParam,
  63. searchFunctionButtonList,
  64. saveButtonList,
  65. } from "@/api/sysLanguage.js"
  66. import {
  67. saveTableDefaultList,
  68. getTableDefaultListLanguage,
  69. getTableUserListLanguage,
  70. removerDefault,
  71. removerUser
  72. } from "@/api/table.js"
  73. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  74. export default {
  75. data() {
  76. return {
  77. searchVisible: false,
  78. searchShow: false,
  79. // table高度
  80. height: 450,
  81. // 是否收藏
  82. favorite: false,
  83. addLanguage: false,
  84. functionId: this.$route.meta.menuId,
  85. tableId: "105002003OO",
  86. languageCode: this.$i18n.locale,
  87. queryTable: {
  88. functionId: this.$route.meta.menuId,
  89. tableId: "105002003OO",
  90. languageCode: this.$i18n.locale
  91. },
  92. visible: false,
  93. showDefault: false,
  94. queryData: {
  95. day: '',
  96. rollno: '',
  97. partno: ''
  98. },
  99. // 语言词典集合
  100. sysLanguageParams: [],
  101. columnList: [
  102. {
  103. "userId": this.$store.state.user.name,
  104. "tableId": "105002003OO",
  105. "tableName": "其它出库",
  106. "columnProp": "rollno",
  107. "columnLabel": "卷号",
  108. "columnHidden": false,
  109. "columnImage": false,
  110. "columnSortable": false,
  111. "columnWidth": 100,
  112. "format": null,
  113. "sortLv": 0,
  114. "status": true,
  115. "fixed": true,
  116. "serialNumber": null,
  117. "columnType": "string",
  118. "align": null
  119. },
  120. {
  121. "userId": this.$store.state.user.name,
  122. "tableId": "105002003OO",
  123. "tableName": "其它出库",
  124. "columnProp": "partno",
  125. "columnLabel": "物料编号",
  126. "columnHidden": false,
  127. "columnImage": false,
  128. "columnSortable": false,
  129. "columnWidth": 100,
  130. "format": null,
  131. "sortLv": 1,
  132. "status": true,
  133. "fixed": false,
  134. "serialNumber": null,
  135. "columnType": "string",
  136. "align": null
  137. },
  138. {
  139. "userId": this.$store.state.user.name,
  140. "tableId": "105002003OO",
  141. "tableName": "其它出库",
  142. "columnProp": "partDescription",
  143. "columnLabel": "物料描述",
  144. "columnHidden": false,
  145. "columnImage": false,
  146. "columnSortable": false,
  147. "columnWidth": 250,
  148. "format": null,
  149. "sortLv": 2,
  150. "status": true,
  151. "fixed": false,
  152. "serialNumber": null,
  153. "columnType": "string",
  154. "align": null
  155. },
  156. {
  157. "userId": this.$store.state.user.name,
  158. "tableId": "105002003OO",
  159. "tableName": "其它出库",
  160. "columnProp": "site",
  161. "columnLabel": "工厂编号",
  162. "columnHidden": false,
  163. "columnImage": false,
  164. "columnSortable": false,
  165. "columnWidth": 80,
  166. "format": null,
  167. "sortLv": 3,
  168. "status": true,
  169. "fixed": false,
  170. "serialNumber": null,
  171. "columnType": "string",
  172. "align": null
  173. },
  174. {
  175. "userId": this.$store.state.user.name,
  176. "tableId": "105002003OO",
  177. "tableName": "其它出库",
  178. "columnProp": "status",
  179. "columnLabel": "状态",
  180. "columnHidden": false,
  181. "columnImage": false,
  182. "columnSortable": false,
  183. "columnWidth": 80,
  184. "format": null,
  185. "sortLv": 5,
  186. "status": true,
  187. "fixed": false,
  188. "serialNumber": null,
  189. "columnType": "number",
  190. "align": null
  191. },
  192. {
  193. "userId": this.$store.state.user.name,
  194. "tableId": "105002003OO",
  195. "tableName": "其它出库",
  196. "columnProp": "rolltype",
  197. "columnLabel": "卷类型",
  198. "columnHidden": false,
  199. "columnImage": false,
  200. "columnSortable": false,
  201. "columnWidth": 80,
  202. "format": null,
  203. "sortLv": 7,
  204. "status": true,
  205. "fixed": false,
  206. "serialNumber": null,
  207. "columnType": "string",
  208. "align": null
  209. },
  210. {
  211. "userId": this.$store.state.user.name,
  212. "tableId": "105002003OO",
  213. "tableName": "其它出库",
  214. "columnProp": "rollqty",
  215. "columnLabel": "卷数量",
  216. "columnHidden": false,
  217. "columnImage": false,
  218. "columnSortable": false,
  219. "columnWidth": 80,
  220. "format": null,
  221. "sortLv": 8,
  222. "status": true,
  223. "fixed": false,
  224. "serialNumber": null,
  225. "columnType": "number",
  226. "align": null
  227. },
  228. ],
  229. dataList: [],
  230. buttons: {
  231. add: '添加',
  232. edit: '编辑',
  233. delete: '删除',
  234. deleteList: '批量删除',
  235. outList: '出库',
  236. cz: '操作',
  237. search: '搜索',
  238. download: '导出',
  239. settingTable: '设置列表',
  240. defaultTable: '设置默认配置'
  241. },
  242. dataListLoading: false,
  243. dataListSelections: [],
  244. addOrUpdateVisible: false
  245. }
  246. },
  247. components: {
  248. AddOrUpdate,
  249. column,
  250. search,
  251. excelUpload
  252. },
  253. mounted() {
  254. this.$nextTick(() => {
  255. this.height = window.innerHeight - 165;
  256. })
  257. },
  258. activated() {
  259. },
  260. methods: {
  261. // 批量出库
  262. async batchOut() {
  263. if (this.dataList.length === 0) {
  264. this.$message.warning("请先导入数据!")
  265. } else {
  266. let status = JSON.parse(JSON.stringify(this.dataList)).filter(item => item.statusDb !== 'I')
  267. let flag = true
  268. if (status.length > 0) {
  269. this.$message.warning("数据中包含不在库的卷!")
  270. await this.$confirm('数据中包含不在库的卷, 是否继续?', '提示', {
  271. confirmButtonText: '确定',
  272. cancelButtonText: '取消',
  273. type: 'warning'
  274. }).then(() => {
  275. }).catch(() => {
  276. flag = false
  277. });
  278. }
  279. if (flag){
  280. let dataList = JSON.parse(JSON.stringify(this.dataList)).filter(item => item.statusDb === 'I').map(item => {
  281. item.statusDb = 'D'
  282. item.status = '已消耗'
  283. return item;
  284. })
  285. batchRollUpdateStatus(dataList).then(({data}) => {
  286. if (data.code === 0) {
  287. this.dataList = []
  288. this.$message.success('出库成功')
  289. } else {
  290. this.$message.warning('出库失败')
  291. }
  292. })
  293. }
  294. }
  295. },
  296. // 移除行
  297. deleteRoll(row) {
  298. this.dataList = this.dataList.filter(item => item.rollno !== row.rollno)
  299. },
  300. excelUploadChild(childValue) {
  301. // childValue就是子组件传过来的值
  302. if (childValue.list.length > 0) {
  303. this.dataList = childValue.list
  304. this.$message.success("导入数据成功")
  305. } else {
  306. this.$message.warning("导入数据失败,请检查导入的数据")
  307. }
  308. },
  309. // 校验用户是否收藏
  310. favoriteIsOk() {
  311. let userFavorite = {
  312. userId: this.$store.state.user.id,
  313. languageCode: this.$i18n.locale
  314. }
  315. userFavoriteList(userFavorite).then(({data}) => {
  316. let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
  317. if (size > 0) {
  318. this.favorite = true
  319. } else {
  320. this.favorite = false
  321. }
  322. })
  323. },
  324. // 收藏 OR 取消收藏
  325. favoriteFunction() {
  326. let userFavorite = {
  327. userId: this.$store.state.user.id,
  328. functionId: this.$route.meta.menuId,
  329. }
  330. if (this.favorite) {
  331. // 取消收藏
  332. this.$confirm(`确定取消收藏`, '提示', {
  333. confirmButtonText: '确定',
  334. cancelButtonText: '取消',
  335. type: 'warning'
  336. }).then(() => {
  337. removeUserFavorite(userFavorite).then(({data}) => {
  338. this.$message.success(data.msg)
  339. this.favorite = false
  340. })
  341. })
  342. } else {
  343. // 收藏
  344. saveUserFavorite(userFavorite).then(({data}) => {
  345. this.$message.success(data.msg)
  346. this.favorite = true
  347. })
  348. }
  349. },
  350. // 获取button的词典
  351. getFunctionButtonList() {
  352. let queryButton = {
  353. functionId: this.functionId,
  354. tableId: this.tableId,
  355. languageCode: this.languageCode,
  356. objectType: 'button'
  357. }
  358. searchFunctionButtonList(queryButton).then(({data}) => {
  359. if (data.data.length > 0) {
  360. this.buttons = data.data
  361. }
  362. })
  363. },
  364. // 获取语言词典
  365. getSysLanguageParamList() {
  366. let querySysLanguageParam = {
  367. languageCode: this.$i18n.locale
  368. }
  369. searchSysLanguageParam(querySysLanguageParam).then(({data}) => {
  370. this.sysLanguageParams = data.rows
  371. })
  372. },
  373. // 打开页面设置
  374. userSetting() {
  375. this.visible = true;
  376. let queryTable = {
  377. userId: this.userId,
  378. functionId: this.functionId,
  379. tableId: this.tableId,
  380. languageCode: this.languageCode
  381. }
  382. this.$nextTick(() => {
  383. this.$refs.column.init(queryTable);
  384. });
  385. },
  386. // 获取 用户保存的 格式列
  387. getTableUserColumn() {
  388. let queryTableUser = {
  389. userId: this.userId,
  390. functionId: this.functionId,
  391. tableId: this.tableId,
  392. languageCode: this.languageCode,
  393. objectType: 'table',
  394. status: true,
  395. }
  396. getTableUserListLanguage(queryTableUser).then(({data}) => {
  397. if (data.rows.length > 0) {
  398. //this.columnList = []
  399. this.columnList = data.rows
  400. } else {
  401. this.getColumnList()
  402. }
  403. })
  404. },
  405. // 保存 默认配置 列
  406. async saveColumnList() {
  407. // 删除所有的该页面下保存的数据
  408. if (this.userColumnList) {
  409. //删除 user自定义的数据
  410. await removerUser(this.queryTable)
  411. }
  412. // 删除默认配置
  413. await removerDefault(this.queryTable)
  414. // 保存页面 table属性
  415. let sumColumnList = this.columnList;
  416. sumColumnList = sumColumnList.map(item => {
  417. return item = {
  418. tableId: item.tableId,
  419. tableName: item.tableName,
  420. columnProp: item.columnProp,
  421. columnLabel: item.columnLabel,
  422. columnHidden: false,
  423. columnImage: false,
  424. columnSortable: false,
  425. columnWidth: item.columnWidth,
  426. format: item.format,
  427. functionId: this.$route.meta.menuId,
  428. sortLv: item.sortLv,
  429. status: true,
  430. fixed: item.fixed,
  431. serialNumber: item.serialNumber,
  432. columnType: item.columnType,
  433. align: item.align
  434. }
  435. })
  436. await saveTableDefaultList(sumColumnList)
  437. // 保存页面 button label title 属性
  438. let buttons = this.buttonList.map(item => {
  439. return item = {
  440. functionId: this.$route.meta.menuId,
  441. languageValue: item.languageValue,
  442. objectId: item.objectId,
  443. objectType: item.objectType,
  444. tableId: item.tableId
  445. }
  446. })
  447. await saveButtonList(buttons)
  448. this.getFunctionButtonList()
  449. this.getColumnList()
  450. },
  451. // // 保存 默认配置 列
  452. // saveColumnList() {
  453. // // this.showDefault = false
  454. // saveButtonList(this.buttonList).then(({data}) => {
  455. // })
  456. // saveTableDefaultList(this.columnList).then(({data}) => {
  457. // if (data.code == 0) {
  458. // this.$message.success(data.msg)
  459. // // this.showDefault = false
  460. // } else {
  461. // // this.showDefault = true
  462. // this.$message.error(data.msg)
  463. // }
  464. // })
  465. // this.getFunctionButtonList();
  466. // this.getColumnList()
  467. // },
  468. // 获取 tableDefault 列
  469. getColumnList() {
  470. let queryTable = {
  471. functionId: this.functionId,
  472. tableId: this.tableId,
  473. languageCode: this.languageCode
  474. }
  475. getTableDefaultListLanguage(queryTable).then(({data}) => {
  476. if (!data.rows.length == 0) {
  477. // this.showDefault = false
  478. this.columnList = data.rows
  479. } else {
  480. // this.showDefault = true
  481. }
  482. })
  483. },
  484. },
  485. created() {
  486. this.getTableUserColumn()
  487. this.getSysLanguageParamList()
  488. this.getFunctionButtonList()
  489. this.favoriteIsOk()
  490. }
  491. }
  492. </script>
  493. <style scoped>
  494. .sl-svg {
  495. overflow: hidden;
  496. float: right;
  497. }
  498. .el-button--small, .el-button--small.is-round {
  499. padding: 5px 10px;
  500. }
  501. </style>