basic-data.js 22 KB

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