basic-data.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. countByCondMoneyAccount(dataId, service, item, id) {
  337. this.excute(this.data.service, this.data.service.countByCondMoneyAccount + '/' + dataId, {}).then(res => {
  338. console.log(res, service)
  339. if (res.data.code == 200) {
  340. if (res.data.data > 0 && item.flgValid) {
  341. //提示信息
  342. Dialog.confirm({
  343. message: '账户类别有资金账户不能停用',
  344. }).then(() => { }).catch(() => {
  345. });
  346. return
  347. } else {
  348. //执行接口
  349. this.handleMoreDataIsValid(service, item, id)
  350. }
  351. }
  352. })
  353. },
  354. /**
  355. * @desc : 分类切换
  356. * @author : 于继渤
  357. * @date : 2022/5/26 20:16
  358. */
  359. changeSidebar(e) {
  360. let detail = e.detail
  361. if (!detail) {
  362. this.setData({
  363. sideKey: null
  364. })
  365. } else {
  366. this.setData({
  367. sideKey: e.detail
  368. })
  369. }
  370. this.setData({
  371. formDataName: this.data.sidebarList[detail].kindName,
  372. dictCode: this.data.sidebarList[detail].kindCode
  373. })
  374. this.setPopContent();
  375. this.searchData()
  376. },
  377. handleData() {
  378. this.searchData()
  379. },
  380. /**
  381. * @desc : 列表对象点击
  382. * @author : 于继渤
  383. * @date : 2024/1/23 9:16
  384. */
  385. toDetail(e) {
  386. let item = e.detail.item
  387. this.setPopContent(item);
  388. this.setData({
  389. popContent: this.data.popContent,
  390. showPop: true,
  391. dataItem: JSON.stringify(item),
  392. historyDataItem: item
  393. })
  394. },
  395. /**
  396. * @desc : 新建
  397. * @author : 于继渤
  398. * @date : 2024/1/23 9:16
  399. */
  400. toAdd() {
  401. this.setPopContent();
  402. this.setData({
  403. dataItem: null,
  404. formData: null,
  405. showPop: true,
  406. })
  407. //清除组件数据
  408. this.selectComponent('#popup').setFormNull()
  409. if (this.data.dictCode == mixins.$t('warehouseSys')) {
  410. let dataItemData = {}
  411. dataItemData['supervisor'] = app.globalData.user.staffName
  412. dataItemData['contactPhone'] = app.globalData.user.userPhone
  413. //设置默认主管
  414. this.setData({
  415. dataItem: JSON.stringify(dataItemData)
  416. })
  417. }
  418. },
  419. /**
  420. * @desc : 跳转排序
  421. * @author : 于继渤
  422. * @date : 2024/1/23 9:16
  423. */
  424. toSort() {
  425. let this_ = this
  426. wx.navigateTo({
  427. url: this.data.route.sort.url,
  428. success: function (res) {
  429. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  430. res.eventChannel.emit('params', {
  431. formType: this_.data.dictCode,
  432. formMode: 'index'
  433. })
  434. }
  435. })
  436. },
  437. /**
  438. * @desc : 设置查询参数
  439. * @author : 于继渤
  440. * @date : 2024/1/23 9:16
  441. */
  442. setSearchParams(params) {
  443. params.flgValidList = params.flgValidList ? params.flgValidList : [true]
  444. params.dictCode = this.data.dictCode
  445. return params
  446. },
  447. /**
  448. * @desc : 加载数据
  449. * @author : 于继渤
  450. * @date : 2024/1/23 9:16
  451. */
  452. getData(params) {
  453. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  454. return this.excute(this.data.warehouseService, this.data.warehouseService.selectByCond, params);
  455. } else if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  456. return this.excute(this.data.saleChannelService, this.data.saleChannelService.selectByCond, params);
  457. } else {
  458. //基础数据接口
  459. return this.excute(this.data.service, this.data.service.selectByCond, params);
  460. }
  461. },
  462. /**
  463. * @desc : 获取左侧数据
  464. * @date : 2024/2/1 15:49
  465. * @author : 于继渤
  466. */
  467. getDataKind() {
  468. // 读取系统字典
  469. let sidebarList = app.globalData.dataKindList.filter(it=>it.kindType == Constants.kindType.basicData)
  470. console.log('gradeCode',this.data.gradeCode);
  471. if (this.data.gradeCode == Constants.gradeCode.STD) {
  472. sidebarList = sidebarList.filter(it => (it.kindCode == '基础资料-仓库' || it.kindCode == '基础资料-账户' ||
  473. it.kindCode == '基础资料-入库' || it.kindCode == '基础资料-渠道'))
  474. }
  475. this.setData({
  476. sidebarList: sidebarList
  477. })
  478. },
  479. /**
  480. * @desc : 处理接口返回数据
  481. * @date : 2024/2/1 15:49
  482. * @author : 于继渤
  483. */
  484. handleSearchData(tableData) {
  485. tableData.forEach(res => {
  486. res.listItemTitle = this.data.dictCode
  487. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  488. res.title = res.whName
  489. res['flgDefaultDisabled'] = res.flgDefault
  490. } else if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  491. res.title = res.channelName
  492. res['flgDefaultDisabled'] = res.flgDefault
  493. } else {
  494. res.title = res.dataValue
  495. }
  496. })
  497. this.setData({
  498. tableData: tableData
  499. })
  500. },
  501. /**
  502. * @desc : 新建编辑事件
  503. * @author : 于继渤
  504. * @date : 2024/1/26 11:46
  505. */
  506. editItems(e) {
  507. let data = e.detail.form
  508. this.setData({
  509. formData: JSON.stringify(data)
  510. })
  511. //执行保存编辑操作
  512. this.save({})
  513. },
  514. /**
  515. * @desc : 保存编辑
  516. * @author : 于继渤
  517. * @date : 2022/5/26 20:16
  518. */
  519. saveData(params) {
  520. let id = null
  521. let service = null
  522. let historyDataItem = this.data.historyDataItem
  523. if (this.data.dictCode == mixins.$t('warehouseSys')) { //仓库档案
  524. service = this.data.warehouseService
  525. id = params.whId
  526. if (id && !historyDataItem.flgDefault && params.flgDefault) {
  527. //判断默认给提示
  528. this.isFlgDefault(id, historyDataItem, params, service)
  529. return
  530. }
  531. } else
  532. if (this.data.dictCode == mixins.$t('saleChannelSys')) { //销售渠道
  533. service = this.data.saleChannelService
  534. id = params.channelId
  535. if (id && !historyDataItem.flgDefault && params.flgDefault) {
  536. //判断默认给提示
  537. this.isFlgDefault(id, historyDataItem, params, service)
  538. return
  539. }
  540. } else { //基础数据
  541. service = this.data.service
  542. id = params.dataId
  543. params.dictCode = this.data.dictCode
  544. if (id && !historyDataItem.flgDefault && params.flgDefault && this.data.dictCode == '基础资料-账户') {
  545. //判断默认给提示
  546. this.isFlgDefault(id, historyDataItem, params, service)
  547. return
  548. }
  549. }
  550. if (id) { //编辑
  551. if (this.data.dictCode == '基础资料-账户') {
  552. if (this.data.gradeCode == Constants.gradeCode.STD) { //标准
  553. params.gradeCode = this.data.gradeCode
  554. // params.orgId = app.globalData.user.orgId
  555. }
  556. }
  557. return this.excute(service, service.update, params).then(result => {
  558. if (result && result.data && result.data.code === Constants.SUCESS_CODE) {
  559. wx.showToast({
  560. title: '保存成功',
  561. image: '/static/image/success.png',
  562. duration: 2000
  563. })
  564. // 执行查询方法
  565. this.searchData()
  566. // 编辑关闭弹出pop
  567. this.setData({
  568. showPop: false
  569. })
  570. }
  571. });
  572. } else { //新建
  573. this.isFlgDefaultSave(service).then(it => {
  574. console.log(it, params)
  575. if (!it && params.flgDefault) {
  576. //存在默认
  577. Dialog.confirm({
  578. message: mixins.$t('defaultInfo'),
  579. }).then(() => {
  580. return this.excute(service, service.insert, params).then(res => {
  581. if (res.data.code === Constants.SUCESS_CODE) {
  582. wx.showToast({
  583. title: '保存成功',
  584. image: '/static/image/success.png',
  585. duration: 2000
  586. })
  587. // 重新查询
  588. this.searchData()
  589. //清除组件数据
  590. this.selectComponent('#popup').setFormNull()
  591. }
  592. })
  593. }).catch(() => {
  594. this.setData({
  595. dataItem: null
  596. })
  597. // 不清除组件数据 关闭蒙层
  598. this.selectComponent('#popup').setLoading(false)
  599. return
  600. });
  601. } else {
  602. if (this.data.dictCode == '基础资料-账户') {
  603. if (this.data.gradeCode == Constants.gradeCode.STD) { //标准
  604. params.gradeCode = this.data.gradeCode
  605. params.orgId = app.globalData.user.orgId
  606. }
  607. }
  608. return this.excute(service, service.insert, params).then(result => {
  609. if (result && result.data && result.data.code === Constants.SUCESS_CODE) {
  610. wx.showToast({
  611. title: '保存成功',
  612. image: '/static/image/success.png',
  613. duration: 2000
  614. })
  615. // 执行查询方法
  616. this.searchData()
  617. //清除组件数据
  618. this.selectComponent('#popup').setFormNull()
  619. }
  620. });
  621. }
  622. })
  623. }
  624. },
  625. /**
  626. * @desc : 编辑默认设置提示
  627. * @author : 于继渤
  628. * @date : 2022/5/26 20:16
  629. */
  630. isFlgDefault(id, historyDataItem, params, service) {
  631. Dialog.confirm({
  632. message: '已存在默认,是否要新作默认',
  633. }).then(() => {
  634. this.excute(service, service.update, params).then(res => {
  635. console.log(res)
  636. if (res.data.code === Constants.SUCESS_CODE) {
  637. wx.showToast({
  638. title: '保存成功',
  639. image: '/static/image/success.png',
  640. duration: 2000
  641. })
  642. // 重新查询
  643. this.searchData()
  644. }
  645. })
  646. }).catch(() => {
  647. console.log('setFormNull')
  648. //清除组件数据
  649. this.setData({
  650. dataItem: null
  651. })
  652. this.selectComponent('#popup').setFormNull()
  653. });
  654. },
  655. /**
  656. * @desc : 新建默认设置提示
  657. * @author : 于继渤
  658. * @date : 2022/5/26 20:16
  659. */
  660. isFlgDefaultSave(service) {
  661. this.setData({
  662. loading:false
  663. })
  664. return new Promise((resolve, reject) => {
  665. this.excute(service, service.selectByCond, {
  666. flgDefault: true
  667. }).then(res => {
  668. if (res.data.data.list && res.data.data.list.length > 0) {
  669. resolve(false)
  670. } else {
  671. resolve(true)
  672. }
  673. })
  674. })
  675. },
  676. /**
  677. * 生命周期函数--监听页面加载
  678. */
  679. onLoad(options) {
  680. this.getDataKind()
  681. let _this = this;
  682. wx.getSystemInfo({
  683. success: function (res) {
  684. _this.setData({
  685. windowHeight: res.windowHeight,
  686. windowWidth: res.windowWidth
  687. })
  688. }
  689. })
  690. },
  691. })