BillListMixin.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import Vue from 'vue'
  2. import { getAction } from '@/api/manage'
  3. import { FormTypes } from '@/utils/JEditableTableUtil'
  4. import {
  5. findBillDetailByNumber,
  6. findBySelectSup,
  7. findBySelectCus,
  8. findBySelectRetail,
  9. getUserList,
  10. getAccount,
  11. waitBillCount,
  12. getCurrentSystemConfig,
  13. getPlatformConfigByKey,
  14. } from '@/api/api'
  15. import { getCheckFlag, getFormatDate, getPrevMonthFormatDate } from '@/utils/util'
  16. import moment from 'moment'
  17. export const BillListMixin = {
  18. data() {
  19. return {
  20. /* 原始审核是否开启 */
  21. checkFlag: true,
  22. /* 单据Excel是否开启 */
  23. isShowExcel: false,
  24. //以销定购的场景开关
  25. purchaseBySaleFlag: false,
  26. waitTotal: 0,
  27. dateFormat: 'YYYY-MM-DD',
  28. billExcelUrl: '',
  29. supList: [],
  30. cusList: [],
  31. retailList: [],
  32. userList: [],
  33. accountList: [],
  34. // 实际索引
  35. settingDataIndex: [],
  36. // 实际列
  37. columns: [],
  38. queryParam: {
  39. beginTime: getPrevMonthFormatDate(3),
  40. endTime: getFormatDate(),
  41. createTimeRange: [moment(getPrevMonthFormatDate(3)), moment(getFormatDate())],
  42. },
  43. }
  44. },
  45. computed: {
  46. importExcelUrl: function () {
  47. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
  48. },
  49. isBatchDelEnabled: function () {
  50. for (let i = 0; i < this.selectedRowKeys.length; i++) {
  51. if (!this.selectionRows[i].actionsEnabled.delete) {
  52. return false
  53. }
  54. }
  55. return true
  56. },
  57. },
  58. created() {
  59. this.initColumnsSetting()
  60. this.isShowExcel = Vue.ls.get('isShowExcel')
  61. },
  62. methods: {
  63. myHandleAdd() {
  64. this.$refs.modalForm.action = 'add'
  65. if (this.btnEnableList.indexOf(2) === -1) {
  66. this.$refs.modalForm.isCanCheck = false
  67. }
  68. this.handleAdd()
  69. },
  70. myHandleCopyAdd(record) {
  71. this.$refs.modalForm.action = 'copyAdd'
  72. if (this.btnEnableList.indexOf(2) === -1) {
  73. this.$refs.modalForm.isCanCheck = false
  74. }
  75. //复制单据的时候需要移除关联单据的相关信息
  76. record.linkNumber = ''
  77. record.billType = ''
  78. record.deposit = ''
  79. this.$refs.modalForm.edit(record)
  80. this.$refs.modalForm.title = '复制新增'
  81. this.$refs.modalForm.disableSubmit = false
  82. //开启明细的编辑模式
  83. this.$refs.modalForm.rowCanEdit = true
  84. let columnIndex = record.subType === '组装单' || record.subType === '拆卸单' ? 2 : 0
  85. this.$refs.modalForm.materialTable.columns[columnIndex].type = FormTypes.popupJsh
  86. },
  87. myHandleEdit(record) {
  88. if (record.status === '0') {
  89. this.$refs.modalForm.action = 'edit'
  90. if (this.btnEnableList.indexOf(2) === -1) {
  91. this.$refs.modalForm.isCanCheck = false
  92. }
  93. //查询单条单据信息
  94. findBillDetailByNumber({ number: record.number }).then((res) => {
  95. if (res && res.code === 200) {
  96. let item = res.data
  97. this.handleEdit(item)
  98. }
  99. })
  100. } else {
  101. this.$message.warning('抱歉,只有未审核的单据才能编辑,请先进行反审核!')
  102. }
  103. },
  104. myHandleDelete(record) {
  105. if (record.status === '0') {
  106. this.handleDelete(record.id)
  107. } else {
  108. this.$message.warning('抱歉,只有未审核的单据才能删除,请先进行反审核!')
  109. }
  110. },
  111. myHandleDetail(record, type, prefixNo) {
  112. if (this.btnEnableList.indexOf(7) === -1) {
  113. this.$refs.modalDetail.isCanBackCheck = false
  114. }
  115. this.handleDetail(record, type, prefixNo)
  116. },
  117. handleApprove(record) {
  118. this.$refs.modalForm.action = 'approve'
  119. this.$refs.modalForm.edit(record)
  120. this.$refs.modalForm.title = '审核'
  121. },
  122. searchReset() {
  123. this.queryParam = {
  124. type: this.queryParam.type,
  125. subType: this.queryParam.subType,
  126. beginTime: getPrevMonthFormatDate(3),
  127. endTime: getFormatDate(),
  128. createTimeRange: [moment(getPrevMonthFormatDate(3)), moment(getFormatDate())],
  129. }
  130. this.loadData(1)
  131. },
  132. onDateChange: function (value, dateString) {
  133. this.queryParam.beginTime = dateString[0]
  134. this.queryParam.endTime = dateString[1]
  135. if (dateString[0] && dateString[1]) {
  136. this.queryParam.createTimeRange = [moment(dateString[0]), moment(dateString[1])]
  137. }
  138. },
  139. onDateOk(value) {
  140. console.log(value)
  141. },
  142. initSystemConfig() {
  143. getCurrentSystemConfig().then((res) => {
  144. if (res.code === 200 && res.data) {
  145. let multiBillType = res.data.multiBillType
  146. let multiLevelApprovalFlag = res.data.multiLevelApprovalFlag
  147. this.checkFlag = getCheckFlag(multiBillType, multiLevelApprovalFlag, this.prefixNo)
  148. this.purchaseBySaleFlag = res.data.purchaseBySaleFlag === '1' ? true : false
  149. this.inOutManageFlag = res.data.inOutManageFlag === '1' ? true : false
  150. }
  151. })
  152. getPlatformConfigByKey({ platformKey: 'bill_excel_url' }).then((res) => {
  153. if (res && res.code === 200) {
  154. if (res.data.platformValue) {
  155. this.billExcelUrl = res.data.platformValue
  156. }
  157. }
  158. })
  159. },
  160. initSupplier() {
  161. let that = this
  162. findBySelectSup({}).then((res) => {
  163. if (res) {
  164. that.supList = res
  165. }
  166. })
  167. },
  168. initCustomer() {
  169. let that = this
  170. findBySelectCus({}).then((res) => {
  171. if (res) {
  172. that.cusList = res
  173. }
  174. })
  175. },
  176. initRetail() {
  177. let that = this
  178. findBySelectRetail({}).then((res) => {
  179. if (res) {
  180. that.retailList = res
  181. }
  182. })
  183. },
  184. getDepotData() {
  185. getAction('/depot/findDepotByCurrentUser').then((res) => {
  186. if (res.code === 200) {
  187. this.depotList = res.data
  188. } else {
  189. this.$message.info(res.data)
  190. }
  191. })
  192. },
  193. initUser() {
  194. getUserList({}).then((res) => {
  195. if (res) {
  196. this.userList = res
  197. }
  198. })
  199. },
  200. initAccount() {
  201. getAccount({}).then((res) => {
  202. if (res && res.code === 200) {
  203. this.accountList = res.data.accountList
  204. }
  205. })
  206. },
  207. initWaitBillCount(type, subType, status) {
  208. waitBillCount({
  209. search: {
  210. type: type,
  211. subType: subType,
  212. status: status,
  213. },
  214. }).then((res) => {
  215. if (res && res.code === 200) {
  216. this.waitTotal = res.data.total
  217. }
  218. })
  219. },
  220. //加载初始化列
  221. initColumnsSetting() {
  222. let columnsStr = Vue.ls.get(this.prefixNo)
  223. if (columnsStr && columnsStr.indexOf(',') > -1) {
  224. this.settingDataIndex = columnsStr.split(',')
  225. } else {
  226. this.settingDataIndex = this.defDataIndex
  227. }
  228. this.columns = this.defColumns.filter((item) => {
  229. if (this.purchaseBySaleFlag) {
  230. //以销定购-开启
  231. return this.settingDataIndex.includes(item.dataIndex)
  232. } else {
  233. //以销定购-关闭
  234. if (this.prefixNo === 'CGDD') {
  235. //采购订单只显示除了关联订单之外的列
  236. if (item.dataIndex !== 'linkNumber') {
  237. return this.settingDataIndex.includes(item.dataIndex)
  238. }
  239. } else {
  240. return this.settingDataIndex.includes(item.dataIndex)
  241. }
  242. }
  243. })
  244. },
  245. //列设置更改事件
  246. onColChange(checkedValues) {
  247. this.columns = this.defColumns.filter((item) => {
  248. return checkedValues.includes(item.dataIndex)
  249. })
  250. let columnsStr = checkedValues.join()
  251. Vue.ls.set(this.prefixNo, columnsStr)
  252. },
  253. //恢复默认
  254. handleRestDefault() {
  255. Vue.ls.remove(this.prefixNo)
  256. this.initColumnsSetting()
  257. },
  258. //导出单据
  259. handleExport() {
  260. let search = this.getQueryParams().search
  261. this.$refs.billExcelIframe.show(this.model, this.billExcelUrl + '?search=' + search + '&type=1', 150)
  262. this.$refs.billExcelIframe.title = '确认导出'
  263. },
  264. },
  265. }