basic-data.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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. events: {
  441. // 保存成功后刷新页面
  442. refresh: function (data) {
  443. // 刷新一览界面
  444. _this.searchData();
  445. }
  446. },
  447. success: function (res) {
  448. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  449. res.eventChannel.emit('params', {
  450. formType: _this.data.dictCode,
  451. formMode: 'index'
  452. })
  453. }
  454. })
  455. },
  456. /**
  457. * @desc : 设置查询参数
  458. * @author : 于继渤
  459. * @date : 2024/1/23 9:16
  460. */
  461. setSearchParams(params) {
  462. params.flgValidList = params.flgValidList ? params.flgValidList : [true]
  463. params.dictCode = this.data.dictCode
  464. return params
  465. },
  466. /**
  467. * @desc : 加载数据
  468. * @author : 于继渤
  469. * @date : 2024/1/23 9:16
  470. */
  471. getData(params) {
  472. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  473. return this.excute(this.data.warehouseService, this.data.warehouseService.selectByCond, params);
  474. } else if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  475. return this.excute(this.data.saleChannelService, this.data.saleChannelService.selectByCond, params);
  476. } else {
  477. //基础数据接口
  478. return this.excute(this.data.service, this.data.service.selectByCond, params);
  479. }
  480. },
  481. /**
  482. * @desc : 获取左侧数据
  483. * @date : 2024/2/1 15:49
  484. * @author : 于继渤
  485. */
  486. getDataKind() {
  487. // 读取系统字典
  488. let sidebarList = app.globalData.dataKindList.filter(it => it.kindType == Constants.kindType.basicData)
  489. console.log('gradeCode', this.data.gradeCode);
  490. if (this.data.gradeCode == Constants.gradeCode.STD) {
  491. sidebarList = sidebarList.filter(it => (it.kindCode == '基础资料-仓库' || it.kindCode == '基础资料-账户' ||
  492. it.kindCode == '基础资料-入库' || it.kindCode == '基础资料-渠道'))
  493. }
  494. this.setData({
  495. sidebarList: sidebarList
  496. })
  497. },
  498. /**
  499. * @desc : 处理接口返回数据
  500. * @date : 2024/2/1 15:49
  501. * @author : 于继渤
  502. */
  503. handleSearchData(tableData) {
  504. tableData.forEach(res => {
  505. res.listItemTitle = this.data.dictCode
  506. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  507. res.title = res.whName
  508. res['flgDefaultDisabled'] = res.flgDefault
  509. } else if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  510. res.title = res.channelName
  511. res['flgDefaultDisabled'] = res.flgDefault
  512. } else {
  513. res.title = res.dataValue
  514. }
  515. })
  516. this.setData({
  517. tableData: tableData
  518. })
  519. },
  520. /**
  521. * @desc : 新建编辑事件
  522. * @author : 于继渤
  523. * @date : 2024/1/26 11:46
  524. */
  525. editItems(e) {
  526. let data = e.detail.form
  527. this.setData({
  528. formData: JSON.stringify(data)
  529. })
  530. //执行保存编辑操作
  531. this.save({})
  532. },
  533. /**
  534. * @desc : 保存编辑
  535. * @author : 于继渤
  536. * @date : 2022/5/26 20:16
  537. */
  538. saveData(params) {
  539. let id = null
  540. let service = null
  541. let historyDataItem = this.data.historyDataItem
  542. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  543. service = this.data.warehouseService
  544. id = params.whId
  545. if (id && !historyDataItem.flgDefault && params.flgDefault) {
  546. //判断默认给提示
  547. this.isFlgDefault(id, historyDataItem, params, service)
  548. return
  549. }
  550. } else
  551. if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  552. service = this.data.saleChannelService
  553. id = params.channelId
  554. if (id && !historyDataItem.flgDefault && params.flgDefault) {
  555. //判断默认给提示
  556. this.isFlgDefault(id, historyDataItem, params, service)
  557. return
  558. }
  559. } else { //基础数据
  560. service = this.data.service
  561. id = params.dataId
  562. params.dictCode = this.data.dictCode
  563. if (id && !historyDataItem.flgDefault && params.flgDefault && this.data.dictCode == '基础资料-账户') {
  564. //判断默认给提示
  565. this.isFlgDefault(id, historyDataItem, params, service)
  566. return
  567. }
  568. }
  569. if (id) { //编辑
  570. if (this.data.dictCode == '基础资料-账户') {
  571. if (this.data.gradeCode == Constants.gradeCode.STD) { //标准
  572. params.gradeCode = this.data.gradeCode
  573. // params.orgId = app.globalData.user.orgId
  574. }
  575. }
  576. return this.excute(service, service.update, params).then(result => {
  577. if (result && result.data && result.data.code === Constants.SUCESS_CODE) {
  578. wx.showToast({
  579. title: '保存成功',
  580. image: '/static/image/success.png',
  581. duration: 2000
  582. })
  583. // 执行查询方法
  584. this.searchData()
  585. // 编辑关闭弹出pop
  586. this.setData({
  587. showPop: false
  588. })
  589. }
  590. });
  591. } else { //新建
  592. this.isFlgDefaultSave(service).then(it => {
  593. console.log(it, params)
  594. if (!it && params.flgDefault) {
  595. //存在默认
  596. Dialog.confirm({
  597. message: mixins.$t('defaultInfo'),
  598. }).then(() => {
  599. return this.excute(service, service.insert, params).then(res => {
  600. if (res.data.code === Constants.SUCESS_CODE) {
  601. wx.showToast({
  602. title: '保存成功',
  603. image: '/static/image/success.png',
  604. duration: 2000
  605. })
  606. // 重新查询
  607. this.searchData()
  608. //清除组件数据
  609. this.selectComponent('#popup').setFormNull()
  610. }
  611. })
  612. }).catch(() => {
  613. this.setData({
  614. dataItem: null
  615. })
  616. // 不清除组件数据 关闭蒙层
  617. this.selectComponent('#popup').setLoading(false)
  618. return
  619. });
  620. } else {
  621. if (this.data.dictCode == '基础资料-账户') {
  622. if (this.data.gradeCode == Constants.gradeCode.STD) { //标准
  623. params.gradeCode = this.data.gradeCode
  624. params.orgId = app.globalData.user.orgId
  625. }
  626. }
  627. return this.excute(service, service.insert, params).then(result => {
  628. if (result && result.data && result.data.code === Constants.SUCESS_CODE) {
  629. wx.showToast({
  630. title: '保存成功',
  631. image: '/static/image/success.png',
  632. duration: 2000
  633. })
  634. // 执行查询方法
  635. this.searchData()
  636. //清除组件数据
  637. this.selectComponent('#popup').setFormNull()
  638. }
  639. });
  640. }
  641. })
  642. }
  643. },
  644. /**
  645. * @desc : 编辑默认设置提示
  646. * @author : 于继渤
  647. * @date : 2022/5/26 20:16
  648. */
  649. isFlgDefault(id, historyDataItem, params, service) {
  650. Dialog.confirm({
  651. message: '已存在默认,是否要新作默认',
  652. }).then(() => {
  653. this.excute(service, service.update, params).then(res => {
  654. console.log(res)
  655. if (res.data.code === Constants.SUCESS_CODE) {
  656. wx.showToast({
  657. title: '保存成功',
  658. image: '/static/image/success.png',
  659. duration: 2000
  660. })
  661. // 重新查询
  662. this.searchData()
  663. }
  664. })
  665. }).catch(() => {
  666. console.log('setFormNull')
  667. //清除组件数据
  668. this.setData({
  669. dataItem: null
  670. })
  671. this.selectComponent('#popup').setFormNull()
  672. });
  673. },
  674. /**
  675. * @desc : 新建默认设置提示
  676. * @author : 于继渤
  677. * @date : 2022/5/26 20:16
  678. */
  679. isFlgDefaultSave(service) {
  680. this.setData({
  681. loading: false
  682. })
  683. return new Promise((resolve, reject) => {
  684. this.excute(service, service.selectByCond, {
  685. flgDefault: true
  686. }).then(res => {
  687. if (res.data.data.list && res.data.data.list.length > 0) {
  688. resolve(false)
  689. } else {
  690. resolve(true)
  691. }
  692. })
  693. })
  694. },
  695. /**
  696. * 生命周期函数--监听页面加载
  697. */
  698. onLoad(options) {
  699. this.getDataKind()
  700. let _this = this;
  701. wx.getSystemInfo({
  702. success: function (res) {
  703. _this.setData({
  704. windowHeight: res.windowHeight,
  705. windowWidth: res.windowWidth
  706. })
  707. }
  708. })
  709. },
  710. })