basic-data.js 24 KB

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