basic-data.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 编辑履历:
  6. * 作者 日期 版本 修改内容
  7. * 于继渤 2024-1-23 1.00 基础资料
  8. *******************************************************************************/
  9. const Constants = require('@/utils/Constants.js');
  10. const util = require('@/utils/util.js')
  11. import Dialog from '@/dist/dialog/dialog.js';
  12. const mixins = require('@/mixins/index.js')
  13. const app = getApp()
  14. Page({
  15. mixins: [mixins],
  16. /**
  17. * 页面的初始数据
  18. */
  19. data: {
  20. gradeCode: app.globalData.company.gradeCode,
  21. flgValidList: null,
  22. flgDefault: 'flgDefault',
  23. navigateBackFlag: true,
  24. routeObjNameGoTo: '',
  25. formDataName: '仓库',
  26. dictCode: mixins.$t('warehouseSys'),
  27. //接口
  28. warehouseService: app.globalData['warehouseService'],
  29. saleChannelService: app.globalData['saleChannelService'],
  30. commonService: app.globalData['commonService'],
  31. routeObjName: 'basicData',
  32. tableData: [],
  33. buttonSaveList: [{ code: 'sort', title: '排序', width: '120rpx', plain: true }, { code: 'add', title: '新建', width: '120rpx', }],
  34. contentSaveList: [],
  35. // 查询条件
  36. searchContent: [{
  37. code: 'flgValid', key: 'valueList', title: mixins.$t('allValidInvalid'), searchType: Constants.searchType.switch,
  38. list: [
  39. { code: 1, title: mixins.$t('valid'), value: true, checked: true },
  40. { code: 2, title: mixins.$t('invalid'), value: false }]
  41. }],
  42. sidebarList: [],
  43. contentList: [
  44. { name: 'whCode', title: mixins.$t('whCode') },
  45. { name: 'whName', title: mixins.$t('whName') },
  46. { name: 'supervisor', title: mixins.$t('supervisor') }
  47. ],
  48. contentObj: {
  49. //TODO 怎么国际化 ?
  50. // '基础资料-仓库': [{ name: 'whCode', title: mixins.$t('whCode') },
  51. // { name: 'supervisor', title: mixins.$t('supervisor') }],
  52. // '基础资料-渠道': [{ name: 'channelCode', title: mixins.$t('channelCode') },
  53. // ],
  54. // '基础资料-收入': [{ name: 'dataCode', title: mixins.$t('incomeCode') },
  55. // ],
  56. // '基础资料-支出': [{ name: 'dataCode', title: mixins.$t('expenditureCode') },
  57. // ],
  58. // '基础资料-入库': [{ name: 'dataCode', title: mixins.$t('reasonCode') },
  59. // ],
  60. // '基础资料-出库': [{ name: 'dataCode', title: mixins.$t('reasonCode') },
  61. // ],
  62. // '基础资料-账户': [{ name: 'dataCode', title: mixins.$t('accountCode') },
  63. // ],
  64. // '基础资料-来源': [{ name: 'dataCode', title: mixins.$t('sourceCode') },
  65. // ],
  66. // '基础资料-盈亏原因': [{ name: 'dataCode', title: mixins.$t('profitLossCode') },
  67. // ],
  68. },
  69. popContent:
  70. [
  71. { code: 'whCode', type: 'str', title: mixins.$t('whCode'), required: false, readonly: true, },
  72. { code: 'whName', type: 'str', title: mixins.$t('whName'), required: true },
  73. {
  74. name: 'supervisor',
  75. code: 'supervisor',
  76. title: mixins.$t("supervisor"),
  77. type: 'choose',
  78. required: true,
  79. urlKey: 'chooseStaff'
  80. },
  81. { code: 'contactPhone', type: 'str', title: mixins.$t('contactPhone'), required: true },
  82. { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
  83. ],
  84. sideKey: 0,
  85. },
  86. /**
  87. * @desc : 设置pop字段
  88. * @author : 于继渤
  89. * @date : 2024/1/23 9:16
  90. */
  91. setPopContent(item) {
  92. let formDataName = this.data.formDataName
  93. let dictCode = this.data.dictCode
  94. let popContent = this.data.popContent
  95. let contentList = this.data.contentList
  96. let dataItemData = {}
  97. let dataItem = item
  98. let routeObjNameGoTo = this.data.routeObjNameGoTo
  99. this.setData({
  100. flgDefault: 'flgDefault'
  101. })
  102. if (dictCode == mixins.$t('warehouseSys')) {//仓库档案
  103. //设置新建编辑字段
  104. console.log('dictCode', dictCode)
  105. if (dataItem) {
  106. popContent =
  107. [
  108. { code: 'whCode', type: 'str', title: mixins.$t('whCode'), required: false, readonly: true, },
  109. { code: 'whName', type: 'str', title: mixins.$t('whName'), required: true },
  110. {
  111. name: 'supervisor',
  112. code: 'supervisor',
  113. title: mixins.$t("supervisor"),
  114. type: 'choose',
  115. required: true,
  116. urlKey: 'chooseStaff'
  117. },
  118. { code: 'contactPhone', type: 'str', title: mixins.$t('contactPhone'), required: true },
  119. { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
  120. ]
  121. } else {
  122. //新建
  123. popContent =
  124. [
  125. // { code: 'whCode', type: 'str', title: mixins.$t('whCode'), required: false, readonly: true, },
  126. { code: 'whName', type: 'str', title: mixins.$t('whName'), required: true },
  127. {
  128. name: 'supervisor',
  129. code: 'supervisor',
  130. title: mixins.$t("supervisor"),
  131. type: 'choose',
  132. required: true,
  133. urlKey: 'chooseStaff'
  134. },
  135. { code: 'contactPhone', type: 'str', title: mixins.$t('contactPhone'), required: true },
  136. { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
  137. ]
  138. }
  139. routeObjNameGoTo = 'warehouse'
  140. console.log('popContent', popContent)
  141. } else if (dictCode == mixins.$t('saleChannelSys')) {
  142. //设置新建编辑字段
  143. if (dataItem) {
  144. popContent =
  145. [
  146. { code: 'channelCode', type: 'str', title: mixins.$t('channelCode'), required: false, readonly: true, },
  147. { code: 'channelName', type: 'str', title: mixins.$t('channelName'), required: true },
  148. { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
  149. ]
  150. } else {
  151. popContent =
  152. [
  153. // { code: 'channelCode', type: 'str', title: mixins.$t('channelCode'), required: false, readonly: true, },
  154. { code: 'channelName', type: 'str', title: mixins.$t('channelName'), required: true },
  155. { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
  156. ]
  157. }
  158. } else {
  159. if (dictCode == mixins.$t('incomeCategorySys')) {
  160. //设置新建编辑字段 收入类别
  161. if (dataItem) {
  162. popContent =
  163. [
  164. { code: 'dataCode', type: 'str', title: mixins.$t('incomeCode'), required: false, readonly: true, },
  165. { code: 'dataValue', type: 'str', title: mixins.$t('incomeName'), required: true }
  166. ]
  167. } else {
  168. popContent =
  169. [
  170. // { code: 'dataCode', type: 'str', title: mixins.$t('incomeCode'), required: false, readonly: true, },
  171. { code: 'dataValue', type: 'str', title: mixins.$t('incomeName'), required: true }
  172. ]
  173. }
  174. this.setData({
  175. flgDefault: null
  176. })
  177. }
  178. if (dictCode == mixins.$t('expenditureCategorySys')) {
  179. //设置新建编辑字段 支出类别
  180. if (dataItem) {
  181. popContent =
  182. [
  183. { code: 'dataCode', type: 'str', title: mixins.$t('expenditureCode'), required: false, readonly: true, },
  184. { code: 'dataValue', type: 'str', title: mixins.$t('expenditureName'), required: true }
  185. ]
  186. } else {
  187. popContent =
  188. [
  189. // { code: 'dataCode', type: 'str', title: mixins.$t('expenditureCode'), required: false, readonly: true, },
  190. { code: 'dataValue', type: 'str', title: mixins.$t('expenditureName'), required: true }
  191. ]
  192. }
  193. this.setData({
  194. flgDefault: null
  195. })
  196. }
  197. if (dictCode == mixins.$t('reasonStorageSys')) {
  198. //设置新建编辑字段 入库原因
  199. if (dataItem) {
  200. popContent =
  201. [
  202. { code: 'dataCode', type: 'str', title: mixins.$t('reasonCode'), required: false, readonly: true, },
  203. { code: 'dataValue', type: 'str', title: mixins.$t('reasonName'), required: true }
  204. ]
  205. } else {
  206. popContent =
  207. [
  208. // { code: 'dataCode', type: 'str', title: mixins.$t('reasonCode'), required: false, readonly: true, },
  209. { code: 'dataValue', type: 'str', title: mixins.$t('reasonName'), required: true }
  210. ]
  211. }
  212. this.setData({
  213. flgDefault: null
  214. })
  215. }
  216. if (dictCode == mixins.$t('reasonOutboundSys')) {
  217. //设置新建编辑字段 出库原因
  218. if (dataItem) {
  219. popContent =
  220. [
  221. { code: 'dataCode', type: 'str', title: mixins.$t('reasonCode'), required: false, readonly: true, },
  222. { code: 'dataValue', type: 'str', title: mixins.$t('reasonName'), required: true }
  223. ]
  224. } else {
  225. popContent =
  226. [
  227. // { code: 'dataCode', type: 'str', title: mixins.$t('reasonCode'), required: false, readonly: true, },
  228. { code: 'dataValue', type: 'str', title: mixins.$t('reasonName'), required: true }
  229. ]
  230. }
  231. this.setData({
  232. flgDefault: null
  233. })
  234. }
  235. if (dictCode == mixins.$t('accountCategorySys')) {
  236. //设置新建编辑字段 账户类别
  237. if (dataItem) {
  238. popContent =
  239. [
  240. { code: 'dataCode', type: 'str', title: mixins.$t('accountCode'), required: false, readonly: true, },
  241. { code: 'dataValue', type: 'str', title: mixins.$t('accountName'), required: true }
  242. ]
  243. } else {
  244. popContent =
  245. [
  246. // { code: 'dataCode', type: 'str', title: mixins.$t('accountCode'), required: false, readonly: true, },
  247. { code: 'dataValue', type: 'str', title: mixins.$t('accountName'), required: true }
  248. ]
  249. }
  250. this.setData({
  251. flgDefault: null
  252. })
  253. }
  254. if (dictCode == mixins.$t('customerSourceSys')) {
  255. //设置新建编辑字段 客户来源
  256. if (dataItem) {
  257. popContent =
  258. [
  259. { code: 'dataCode', type: 'str', title: mixins.$t('sourceCode'), required: false, readonly: true, },
  260. { code: 'dataValue', type: 'str', title: mixins.$t('sourceName'), required: true },
  261. ]
  262. } else {
  263. popContent =
  264. [
  265. // { code: 'dataCode', type: 'str', title: mixins.$t('sourceCode'), required: false, readonly: true, },
  266. { code: 'dataValue', type: 'str', title: mixins.$t('sourceName'), required: true },
  267. ]
  268. }
  269. }
  270. if (dictCode == mixins.$t('profitLossSys')) {
  271. //设置新建编辑字段 客户来源
  272. if (dataItem) {
  273. popContent =
  274. [
  275. { code: 'dataCode', type: 'str', title: mixins.$t('profitLossCode'), required: false, readonly: true, },
  276. { code: 'dataValue', type: 'str', title: mixins.$t('profitLossName'), required: true },
  277. ]
  278. } else {
  279. popContent =
  280. [
  281. // { code: 'dataCode', type: 'str', title: mixins.$t('profitLossCode'), required: false, readonly: true, },
  282. { code: 'dataValue', type: 'str', title: mixins.$t('profitLossName'), required: true },
  283. ]
  284. }
  285. this.setData({
  286. flgDefault: null
  287. })
  288. }
  289. popContent.push({ code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false })
  290. }
  291. this.setData({
  292. contentList: contentList,
  293. popContent: popContent,
  294. routeObjNameGoTo: routeObjNameGoTo
  295. })
  296. },
  297. /**
  298. * @desc : 底部按钮
  299. * @date : 2024/2/1 15:49
  300. * @author : 于继渤
  301. */
  302. open(e) {
  303. let name = e.detail.name
  304. if (name == 'sort') {
  305. this.toSort()
  306. } else if (name == 'add') {
  307. this.toAdd()
  308. }
  309. },
  310. /**
  311. * @desc : 启用停用
  312. * @date : 2024/2/1 15:49
  313. * @author : 于继渤
  314. */
  315. deactivateEnable(e) {
  316. let item = e.detail.item
  317. let service = null
  318. let id = null
  319. if (this.data.dictCode == mixins.$t('warehouseSys')) {
  320. service = this.data.warehouseService
  321. id = 'whId'
  322. } else if (this.data.dictCode == mixins.$t('saleChannelSys')) {
  323. service = this.data.saleChannelService
  324. id = 'channelId'
  325. } else { //基础数据
  326. service = this.data.service
  327. id = 'dataId'
  328. }
  329. if (this.data.dictCode == mixins.$t('accountCategorySys')) { //账户类别
  330. this.countByCondMoneyAccount(item.dataId, service, item, id)
  331. } else {
  332. //执行接口
  333. this.handleMoreDataIsValid(service, item, id)
  334. }
  335. },
  336. /**
  337. * @desc : 启用停用账户类别
  338. * @date : 2024/5/23 15:49
  339. * @author : 周兴
  340. */
  341. countByCondMoneyAccount(dataId, service, item, id) {
  342. // 标准版需要直接处理,并且处理账户
  343. if (this.data.gradeCode == Constants.gradeCode.STD) {
  344. //执行接口
  345. this.handleMoreDataIsValid(service, item, id)
  346. } else {
  347. // 专业版需要判断是否有账户
  348. this.excute(this.data.service, this.data.service.countByCondMoneyAccount + '/' + dataId, {}).then(res => {
  349. console.log(res, service)
  350. if (res.data.code == 200) {
  351. if (res.data.data > 0 && item.flgValid) {
  352. //提示信息
  353. Dialog.confirm({
  354. message: '账户类别有资金账户不能停用',
  355. }).then(() => { }).catch(() => {
  356. });
  357. return
  358. } else {
  359. //执行接口
  360. this.handleMoreDataIsValid(service, item, id)
  361. }
  362. }
  363. })
  364. }
  365. },
  366. /**
  367. * @desc : 分类切换
  368. * @author : 于继渤
  369. * @date : 2022/5/26 20:16
  370. */
  371. changeSidebar(e) {
  372. let detail = e.detail
  373. if (!detail) {
  374. this.setData({
  375. sideKey: null
  376. })
  377. } else {
  378. this.setData({
  379. sideKey: e.detail
  380. })
  381. }
  382. this.setData({
  383. formDataName: this.data.sidebarList[detail].kindName,
  384. dictCode: this.data.sidebarList[detail].kindCode
  385. })
  386. this.setPopContent();
  387. this.searchData()
  388. },
  389. handleData() {
  390. this.searchData()
  391. },
  392. /**
  393. * @desc : 列表对象点击
  394. * @author : 于继渤
  395. * @date : 2024/1/23 9:16
  396. */
  397. toDetail(e) {
  398. let item = e.detail.item
  399. this.setPopContent(item);
  400. this.setData({
  401. popContent: this.data.popContent,
  402. showPop: true,
  403. dataItem: JSON.stringify(item),
  404. historyDataItem: item
  405. })
  406. },
  407. /**
  408. * @desc : 新建
  409. * @author : 于继渤
  410. * @date : 2024/1/23 9:16
  411. */
  412. toAdd() {
  413. this.setPopContent();
  414. this.setData({
  415. dataItem: null,
  416. formData: null,
  417. showPop: true,
  418. })
  419. //清除组件数据
  420. this.selectComponent('#popup').setFormNull()
  421. if (this.data.dictCode == mixins.$t('warehouseSys')) {
  422. let dataItemData = {}
  423. dataItemData['supervisor'] = app.globalData.user.staffName
  424. dataItemData['contactPhone'] = app.globalData.user.userPhone
  425. //设置默认主管
  426. this.setData({
  427. dataItem: JSON.stringify(dataItemData)
  428. })
  429. }
  430. },
  431. /**
  432. * @desc : 跳转排序
  433. * @author : 于继渤
  434. * @date : 2024/1/23 9:16
  435. */
  436. toSort() {
  437. let this_ = this
  438. wx.navigateTo({
  439. url: this.data.route.sort.url,
  440. success: function (res) {
  441. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  442. res.eventChannel.emit('params', {
  443. formType: this_.data.dictCode,
  444. formMode: 'index'
  445. })
  446. }
  447. })
  448. },
  449. /**
  450. * @desc : 设置查询参数
  451. * @author : 于继渤
  452. * @date : 2024/1/23 9:16
  453. */
  454. setSearchParams(params) {
  455. params.flgValidList = params.flgValidList ? params.flgValidList : [true]
  456. params.dictCode = this.data.dictCode
  457. return params
  458. },
  459. /**
  460. * @desc : 加载数据
  461. * @author : 于继渤
  462. * @date : 2024/1/23 9:16
  463. */
  464. getData(params) {
  465. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  466. return this.excute(this.data.warehouseService, this.data.warehouseService.selectByCond, params);
  467. } else if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  468. return this.excute(this.data.saleChannelService, this.data.saleChannelService.selectByCond, params);
  469. } else {
  470. //基础数据接口
  471. return this.excute(this.data.service, this.data.service.selectByCond, params);
  472. }
  473. },
  474. /**
  475. * @desc : 获取左侧数据
  476. * @date : 2024/2/1 15:49
  477. * @author : 于继渤
  478. */
  479. getDataKind() {
  480. // 读取系统字典
  481. let sidebarList = app.globalData.dataKindList.filter(it => it.kindType == Constants.kindType.basicData)
  482. console.log('gradeCode', this.data.gradeCode);
  483. if (this.data.gradeCode == Constants.gradeCode.STD) {
  484. sidebarList = sidebarList.filter(it => (it.kindCode == '基础资料-仓库' || it.kindCode == '基础资料-账户' ||
  485. it.kindCode == '基础资料-入库' || it.kindCode == '基础资料-渠道'))
  486. }
  487. this.setData({
  488. sidebarList: sidebarList
  489. })
  490. },
  491. /**
  492. * @desc : 处理接口返回数据
  493. * @date : 2024/2/1 15:49
  494. * @author : 于继渤
  495. */
  496. handleSearchData(tableData) {
  497. tableData.forEach(res => {
  498. res.listItemTitle = this.data.dictCode
  499. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  500. res.title = res.whName
  501. res['flgDefaultDisabled'] = res.flgDefault
  502. } else if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  503. res.title = res.channelName
  504. res['flgDefaultDisabled'] = res.flgDefault
  505. } else {
  506. res.title = res.dataValue
  507. }
  508. })
  509. this.setData({
  510. tableData: tableData
  511. })
  512. },
  513. /**
  514. * @desc : 新建编辑事件
  515. * @author : 于继渤
  516. * @date : 2024/1/26 11:46
  517. */
  518. editItems(e) {
  519. let data = e.detail.form
  520. this.setData({
  521. formData: JSON.stringify(data)
  522. })
  523. //执行保存编辑操作
  524. this.save({})
  525. },
  526. /**
  527. * @desc : 保存编辑
  528. * @author : 于继渤
  529. * @date : 2022/5/26 20:16
  530. */
  531. saveData(params) {
  532. let id = null
  533. let service = null
  534. let historyDataItem = this.data.historyDataItem
  535. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  536. service = this.data.warehouseService
  537. id = params.whId
  538. if (id && !historyDataItem.flgDefault && params.flgDefault) {
  539. //判断默认给提示
  540. this.isFlgDefault(id, historyDataItem, params, service)
  541. return
  542. }
  543. } else
  544. if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  545. service = this.data.saleChannelService
  546. id = params.channelId
  547. if (id && !historyDataItem.flgDefault && params.flgDefault) {
  548. //判断默认给提示
  549. this.isFlgDefault(id, historyDataItem, params, service)
  550. return
  551. }
  552. } else { //基础数据
  553. service = this.data.service
  554. id = params.dataId
  555. params.dictCode = this.data.dictCode
  556. if (id && !historyDataItem.flgDefault && params.flgDefault && this.data.dictCode == '基础资料-账户') {
  557. //判断默认给提示
  558. this.isFlgDefault(id, historyDataItem, params, service)
  559. return
  560. }
  561. }
  562. if (id) { //编辑
  563. if (this.data.dictCode == '基础资料-账户') {
  564. if (this.data.gradeCode == Constants.gradeCode.STD) { //标准
  565. params.gradeCode = this.data.gradeCode
  566. // params.orgId = app.globalData.user.orgId
  567. }
  568. }
  569. return this.excute(service, service.update, params).then(result => {
  570. if (result && result.data && result.data.code === Constants.SUCESS_CODE) {
  571. wx.showToast({
  572. title: '保存成功',
  573. image: '/static/image/success.png',
  574. duration: 2000
  575. })
  576. // 执行查询方法
  577. this.searchData()
  578. // 编辑关闭弹出pop
  579. this.setData({
  580. showPop: false
  581. })
  582. }
  583. });
  584. } else { //新建
  585. this.isFlgDefaultSave(service).then(it => {
  586. console.log(it, params)
  587. if (!it && params.flgDefault) {
  588. //存在默认
  589. Dialog.confirm({
  590. message: mixins.$t('defaultInfo'),
  591. }).then(() => {
  592. return this.excute(service, service.insert, params).then(res => {
  593. if (res.data.code === Constants.SUCESS_CODE) {
  594. wx.showToast({
  595. title: '保存成功',
  596. image: '/static/image/success.png',
  597. duration: 2000
  598. })
  599. // 重新查询
  600. this.searchData()
  601. //清除组件数据
  602. this.selectComponent('#popup').setFormNull()
  603. }
  604. })
  605. }).catch(() => {
  606. this.setData({
  607. dataItem: null
  608. })
  609. // 不清除组件数据 关闭蒙层
  610. this.selectComponent('#popup').setLoading(false)
  611. return
  612. });
  613. } else {
  614. if (this.data.dictCode == '基础资料-账户') {
  615. if (this.data.gradeCode == Constants.gradeCode.STD) { //标准
  616. params.gradeCode = this.data.gradeCode
  617. params.orgId = app.globalData.user.orgId
  618. }
  619. }
  620. return this.excute(service, service.insert, params).then(result => {
  621. if (result && result.data && result.data.code === Constants.SUCESS_CODE) {
  622. wx.showToast({
  623. title: '保存成功',
  624. image: '/static/image/success.png',
  625. duration: 2000
  626. })
  627. // 执行查询方法
  628. this.searchData()
  629. //清除组件数据
  630. this.selectComponent('#popup').setFormNull()
  631. }
  632. });
  633. }
  634. })
  635. }
  636. },
  637. /**
  638. * @desc : 编辑默认设置提示
  639. * @author : 于继渤
  640. * @date : 2022/5/26 20:16
  641. */
  642. isFlgDefault(id, historyDataItem, params, service) {
  643. Dialog.confirm({
  644. message: '已存在默认,是否要新作默认',
  645. }).then(() => {
  646. this.excute(service, service.update, params).then(res => {
  647. console.log(res)
  648. if (res.data.code === Constants.SUCESS_CODE) {
  649. wx.showToast({
  650. title: '保存成功',
  651. image: '/static/image/success.png',
  652. duration: 2000
  653. })
  654. // 重新查询
  655. this.searchData()
  656. }
  657. })
  658. }).catch(() => {
  659. console.log('setFormNull')
  660. //清除组件数据
  661. this.setData({
  662. dataItem: null
  663. })
  664. this.selectComponent('#popup').setFormNull()
  665. });
  666. },
  667. /**
  668. * @desc : 新建默认设置提示
  669. * @author : 于继渤
  670. * @date : 2022/5/26 20:16
  671. */
  672. isFlgDefaultSave(service) {
  673. this.setData({
  674. loading: false
  675. })
  676. return new Promise((resolve, reject) => {
  677. this.excute(service, service.selectByCond, {
  678. flgDefault: true
  679. }).then(res => {
  680. if (res.data.data.list && res.data.data.list.length > 0) {
  681. resolve(false)
  682. } else {
  683. resolve(true)
  684. }
  685. })
  686. })
  687. },
  688. /**
  689. * 生命周期函数--监听页面加载
  690. */
  691. onLoad(options) {
  692. this.getDataKind()
  693. let _this = this;
  694. wx.getSystemInfo({
  695. success: function (res) {
  696. _this.setData({
  697. windowHeight: res.windowHeight,
  698. windowWidth: res.windowWidth
  699. })
  700. }
  701. })
  702. },
  703. })