tools.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import store from '@/store'
  2. // 请求头文件
  3. export function axiosRequestParams(_this) {
  4. return {
  5. timeout: 20000,
  6. baseURL: process.env.VUE_APP_BASE_URL,
  7. headers: {
  8. Authorization: 'Bearer ' + store.getters.woptoken,
  9. Identifier: store.getters.wopidntf
  10. }
  11. }
  12. }
  13. // 自定义按钮
  14. export function custFormBtnList(type = 3) {
  15. const bottonList = {
  16. iShow: true,
  17. list: []
  18. }
  19. const btnList = []
  20. if ((type & 1) == 1) {
  21. btnList.push({ bType: 'info', icon: 'el-icon-close', type: 'cancel', label: '取消' })
  22. }
  23. if ((type & 2) == 2) {
  24. btnList.push({ bType: 'primary', icon: 'el-icon-check', type: 'ok', label: '确认' })
  25. }
  26. bottonList.list = btnList
  27. return bottonList
  28. }
  29. // form表单按钮 type:5 使用默认保存功能
  30. export function custFormBtnListNew(type = 4) {
  31. const rv = custFormBtnList()
  32. if (type === 4) {
  33. rv.list[0].type = 'close'
  34. rv.list[1].type = 'submit'
  35. }
  36. return rv
  37. }
  38. /** 装饰数据行,装饰后可使用nt-from表单默认保存功能 */
  39. export function decorateSaveRow(row, ext) {
  40. row._btn = custFormBtnListNew(4)
  41. row._axios = axiosRequestParams()
  42. row._url = ext.url
  43. row._method = 'post'
  44. row._oldData = Object.assign({}, row)
  45. return row
  46. }