basic-data.js 23 KB

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