微信小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. // pages/contract/add/add.js
  2. import * as UTIL from '../../../utils/util.js';
  3. import * as API from '../../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. id:null,
  12. form:{
  13. reviewTime:'2022-01-01',
  14. buildTime:'2022-01-01',
  15. startTime:'2022-01-01',
  16. endTime:'2022-01-01',
  17. biddingDate:'2022-01-01',
  18. fixedValue:'',
  19. fixedSubject:'153:固定资产清理',
  20. depreciationSubject:'152:累计折旧',
  21. depreciationFeeSubject:'541005:管理费用-折旧及修理费',
  22. originalValue:0.00,
  23. quantity:0.00,
  24. netValue:0.00,
  25. residualsRate:1,
  26. netSalvage:0.00,
  27. expectedYears:1,
  28. depreciationYears:0,
  29. depreciationValue:0,
  30. perYearDepreciationValue:0,
  31. },
  32. assetTypeindex:'0',
  33. operationTypendex:'0',
  34. addTypeindex:'0',
  35. useTypeindex:'0',
  36. depreciationTypeindex:'0',
  37. assetStatusindex:'0',
  38. isFormAssetindex:'0',
  39. isMinindex:'0',
  40. unitindex:'0',
  41. showBiddingDate:false,
  42. minDate: new Date(2008, 5, 1).getTime(),
  43. maxDate: new Date(2040, 0, 31).getTime(),
  44. // 资产类别字典
  45. assetTypeOptions: [],
  46. // 经营属性字典
  47. operationTypeOptions: [],
  48. // 增加方式字典
  49. addTypeOptions: [],
  50. // 使用情况字典
  51. useTypeOptions: [],
  52. // 折旧方式字典
  53. depreciationTypeOptions: [],
  54. // 资产状态字典
  55. assetStatusOptions: [],
  56. // 系统是否字典
  57. sysYesNoOptions: [],
  58. //单位字段
  59. unitOptions:[],
  60. status:0,
  61. },
  62. back:function(){
  63. wx.navigateBack({
  64. delta: 1
  65. })
  66. },
  67. openBox(even){
  68. this.setData({
  69. [even.currentTarget.dataset.name]:true
  70. })
  71. },
  72. onChange(event){
  73. this.setData({
  74. [event.currentTarget.dataset.formname]: event.detail,
  75. })
  76. },
  77. closeBox(even){
  78. this.setData({
  79. [even.currentTarget.dataset.name]:false
  80. })
  81. },
  82. onConfirmBuildTime(e){
  83. let data = this.getNewDate(new Date(e.detail.value));
  84. this.setData({'form.buildTime':data});
  85. },
  86. onConfirmOperationType (e) {
  87. let obj = e.detail.value;
  88. this.setData({
  89. 'form.operationType':this.data.operationTypeOptions[obj].dictValue,
  90. 'operationTypeindex':obj
  91. })
  92. },
  93. onConfirmAddType (e) {
  94. let obj = e.detail.value;
  95. this.setData({
  96. 'form.addType':this.data.addTypeOptions[obj].dictValue,
  97. 'addTypeindex':obj
  98. })
  99. },
  100. onConfirmUseType (e) {
  101. let obj = e.detail.value;
  102. this.setData({
  103. 'form.useType':this.data.useTypeOptions[obj].dictValue,
  104. 'useTypeindex':obj
  105. })
  106. },
  107. onConfirmAssetStatus (e) {
  108. let obj = e.detail.value;
  109. this.setData({
  110. 'form.assetStatus':this.data.assetStatusOptions[obj].dictValue,
  111. 'assetStatusindex':obj
  112. })
  113. },
  114. onConfirmIsMin (e) {
  115. console.log(e);
  116. let obj = e.detail.value;
  117. this.setData({
  118. 'form.isMin':this.data.sysYesNoOptions[obj].dictValue,
  119. 'isMinindex':obj
  120. })
  121. },
  122. onConfirmAssetType (e) {
  123. let obj = e.detail.value;
  124. this.setData({
  125. 'form.assetType':this.data.assetTypeOptions[obj].dictValue,
  126. 'assetTypeindex':obj
  127. })
  128. },
  129. onConfirmIsFormAsset (e) {
  130. let obj = e.detail.value;
  131. this.setData({
  132. 'form.isFormAsset':this.data.sysYesNoOptions[obj].dictValue,
  133. 'isFormAssetindex':obj
  134. })
  135. },
  136. onConfirmUnit (e) {
  137. let obj = e.detail.value;
  138. this.setData({
  139. 'form.unit':this.data.unitOptions[obj].dictValue,
  140. 'unitindex':obj
  141. })
  142. },
  143. onConfirmDepreciationType (e) {
  144. let obj = e.detail.value;
  145. this.setData({
  146. 'form.depreciationType':this.data.depreciationTypeOptions[obj].dictValue,
  147. 'depreciationTypeindex':obj
  148. })
  149. },
  150. getNewDate(date){
  151. //date是传过来的时间戳,注意需为13位,10位需*1000
  152. //也可以不传,获取的就是当前时间
  153. var time
  154. if(date){
  155. time = new Date(date);
  156. }else{
  157. time = new Date();
  158. }
  159. var year= time.getFullYear() //年
  160. var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
  161. var day = ("0" + time.getDate()).slice(-2); //日
  162. var mydate = year + "-" + month + "-" + day;
  163. return mydate
  164. },
  165. goSubmit:function(){
  166. if(this.data.form.code==''||this.data.form.code==null){ //合同编码
  167. UTIL.showToastNoneIcon('请填写资产编码!');
  168. return false;
  169. }else if(this.data.form.name==''||this.data.form.name==null){ //合同名称
  170. UTIL.showToastNoneIcon('请输入资产名称!');
  171. return false;
  172. }else if(this.data.form.assetType==''||this.data.form.assetType==null){ //甲方
  173. UTIL.showToastNoneIcon('资产类别不能为空!');
  174. return false;
  175. }else if(this.data.form.operationType==''||this.data.form.operationType==null){ //乙方
  176. UTIL.showToastNoneIcon('经营属性不能为空!');
  177. return false;
  178. }else if(this.data.form.addType == ''||this.data.form.addType==null){//收付款类型
  179. UTIL.showToastNoneIcon('增加方式能为空!');
  180. return false;
  181. }else if(this.data.form.buildTime == ''||this.data.form.buildTime==null){//合同来源
  182. UTIL.showToastNoneIcon('构建时间不能为空!');
  183. return false;
  184. }else if(this.data.form.useType == ''||this.data.form.useType==null){//合同金额
  185. UTIL.showToastNoneIcon('使用情况不能为空!');
  186. return false;
  187. }else if(this.data.form.assetStatus == ''||this.data.form.assetStatus==null){//签订日期
  188. UTIL.showToastNoneIcon('资产状态不能为空!');
  189. return false;
  190. }else if(this.data.form.quantity == ''||this.data.form.quantity==null){//开始日期
  191. UTIL.showToastNoneIcon('请输入数量、面积!');
  192. return false;
  193. }else if(this.data.form.unit == ''||this.data.form.unit==null){//结束日期
  194. UTIL.showToastNoneIcon('计量单位不能为空!');
  195. return false;
  196. }else if(this.data.form.originalValue == ''||this.data.form.originalValue==null){//单价
  197. UTIL.showToastNoneIcon('原值不能为空!');
  198. return false;
  199. }else if(this.data.form.depreciationType == ''||this.data.form.depreciationType==null){//已结款
  200. UTIL.showToastNoneIcon('折旧方式不能为空!');
  201. return false;
  202. }else if(this.data.status == '0'){
  203. this.setData({'status':'1'})
  204. if(this.data.form.id!=null&&this.data.form.id!=""){
  205. let data = this.data.form;
  206. data.method = "POST";
  207. UTIL.httpRequest(API.URL_POST_PERMANENTUPDATE,data,{
  208. success: (res) => {
  209. if(res.code == 200){
  210. UTIL.showToastNoneIcon('修改成功');
  211. setTimeout(function(){
  212. wx.navigateBack({
  213. delta:1
  214. })
  215. },2000)
  216. }else{
  217. UTIL.showToastNoneIcon('修改失败');
  218. this.setData({'status':'0'})
  219. }
  220. },
  221. fail: function (response) {
  222. if (typeof fail === FUNCTION_TEXT) {
  223. fail(handleFail(response));
  224. } else {
  225. showToastNoneIcon(API.MSG_FAIL_HTTP);
  226. }
  227. this.setData({'status':0})
  228. },
  229. complete: function (response) {
  230. this.setData({'status':0})
  231. wx.hideNavigationBarLoading();
  232. }
  233. })
  234. }else{
  235. let data = this.data.form;
  236. data.method = "POST";
  237. UTIL.httpRequest(API.URL_POST_PERMANENTADD,data,{
  238. success: (res) => {
  239. if(res.code == 200){
  240. UTIL.showToastNoneIcon(res.msg);
  241. setTimeout(function(){
  242. wx.navigateBack({
  243. delta:1
  244. })
  245. },2000)
  246. }else{
  247. UTIL.showToastNoneIcon(res.msg);
  248. this.setData({'status':'0'})
  249. }
  250. },
  251. fail: function (response) {
  252. if (typeof fail === FUNCTION_TEXT) {
  253. fail(handleFail(response));
  254. } else {
  255. showToastNoneIcon(API.MSG_FAIL_HTTP);
  256. }
  257. this.setData({'status':0})
  258. },
  259. complete: function (response) {
  260. this.setData({'status':0})
  261. wx.hideNavigationBarLoading();
  262. }
  263. })
  264. }
  265. }
  266. },
  267. bindNewInput: function (e) {
  268. this.setData({
  269. [e.currentTarget.dataset.name]: e.detail.value
  270. })
  271. if(e.currentTarget.dataset.name == 'form.originalValue' ){
  272. this.setData({
  273. 'form.netValue' : e.detail.value,
  274. 'form.netSalvage' : this.data.form.residualsRate*e.detail.value/100,
  275. 'form.perYearDepreciationValue' : (e.detail.value-(this.data.form.residualsRate*e.detail.value/100))/this.data.form.expectedYears.toFixed(2)
  276. })
  277. if(e.currentTarget.dataset.name == 'form.residualsRate' ){
  278. this.setData({
  279. 'form.netSalvage' : this.data.form.originalValue*e.detail.value,
  280. })
  281. }
  282. if(e.currentTarget.dataset.name == 'form.netSalvage' ){
  283. this.setData({
  284. 'form.perYearDepreciationValue' : (this.data.form.originalValue-e.detail.value)/this.data.form.expectedYears.toFixed(2)
  285. })
  286. }
  287. if(e.currentTarget.dataset.name == 'form.expectedYears' ){
  288. this.setData({
  289. 'form.perYearDepreciationValue' : (this.data.form.originalValue-this.data.form.netSalvage)/e.detail.value.toFixed(2)
  290. })
  291. }
  292. if(e.currentTarget.dataset.name == 'form.depreciationYears' ){
  293. this.setData({
  294. 'form.depreciationValue' : this.data.form.netSalvage*e.detail.value
  295. })
  296. }
  297. }
  298. },
  299. /**
  300. * 生命周期函数--监听页面加载
  301. */
  302. onLoad(options) {
  303. if(options.id!=null&&options.id!=""){
  304. this.setData({id:options.id})
  305. //获取收入合同状态
  306. UTIL.httpRequest(API.URL_GET_PERMANENTDETAIL + this.data.id, {method:'GET'}, {
  307. success: (res) => {
  308. this.setData({'form':res.data});
  309. let that = this;
  310. //获取资产类别
  311. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_type', {method:'GET'}, {
  312. success: (r) => {
  313. if(r.data.length>0){
  314. that.setData({
  315. assetTypeOptions:r.data,
  316. })
  317. r.data.map((rr,ind) => {
  318. if(rr.dictValue == res.data.assetType){
  319. that.setData({'assetTypeindex':ind})
  320. }
  321. })
  322. }
  323. }
  324. })
  325. //获取经营属性
  326. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'operation_type', {method:'GET'}, {
  327. success: (r) => {
  328. if(r.data.length>0){
  329. that.setData({
  330. operationTypeOptions:r.data,
  331. })
  332. r.data.map((rr,ind) => {
  333. if(rr.dictValue == res.data.operationType){
  334. that.setData({'operationTypeindex':ind})
  335. }
  336. })
  337. }
  338. }
  339. })
  340. //获取增加方式
  341. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'add_type', {method:'GET'}, {
  342. success: (r) => {
  343. if(r.data.length>0){
  344. that.setData({
  345. addTypeOptions:r.data,
  346. })
  347. r.data.map((rr,ind) => {
  348. if(rr.dictValue == res.data.addType){
  349. that.setData({'addTypeindex':ind})
  350. }
  351. })
  352. }
  353. }
  354. })
  355. //获取使用情况
  356. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'use_type', {method:'GET'}, {
  357. success: (r) => {
  358. if(r.data.length>0){
  359. that.setData({
  360. useTypeOptions:r.data,
  361. })
  362. r.data.map((rr,ind) => {
  363. if(rr.dictValue == res.data.useType){
  364. that.setData({'useTypeindex':ind})
  365. }
  366. })
  367. }
  368. }
  369. })
  370. //获取折旧方式
  371. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'depreciation_type', {method:'GET'}, {
  372. success: (r) => {
  373. if(r.data.length>0){
  374. that.setData({
  375. depreciationTypeOptions:r.data,
  376. })
  377. r.data.map((rr,ind) => {
  378. if(rr.dictValue == res.data.depreciationType){
  379. that.setData({'depreciationTypeindex':ind})
  380. }
  381. })
  382. }
  383. }
  384. })
  385. //获取资产状态
  386. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_status', {method:'GET'}, {
  387. success: (r) => {
  388. if(r.data.length>0){
  389. that.setData({
  390. assetStatusOptions:r.data,
  391. })
  392. r.data.map((rr,ind) => {
  393. if(rr.dictValue == res.data.assetStatus){
  394. that.setData({'assetStatusindex':ind})
  395. }
  396. })
  397. }
  398. }
  399. })
  400. //获取单位
  401. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'fixed_assets_unit', {method:'GET'}, {
  402. success: (r) => {
  403. if(r.data.length>0){
  404. that.setData({
  405. unitOptions:r.data,
  406. })
  407. r.data.map((rr,ind) => {
  408. if(rr.dictValue == res.data.unit){
  409. that.setData({'unitindex':ind})
  410. }
  411. })
  412. }
  413. }
  414. })
  415. //获取系统是否
  416. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'sys_yes_no', {method:'GET'}, {
  417. success: (r) => {
  418. if(r.data.length>0){
  419. that.setData({
  420. sysYesNoOptions:r.data,
  421. })
  422. r.data.map((rr,ind) => {
  423. if(rr.dictValue == res.data.isMin){
  424. that.setData({'isMinindex':ind})
  425. }
  426. if(rr.dictValue == res.data.isFormAsset){
  427. that.setData({'isFormAssetindex':ind})
  428. }
  429. })
  430. }
  431. }
  432. })
  433. }
  434. })
  435. }else{
  436. let that = this;
  437. this.setData({
  438. 'form.reviewTime':this.getNewDate(),
  439. 'form.buildTime':this.getNewDate(),
  440. 'form.startTime':this.getNewDate(),
  441. 'form.endTime':this.getNewDate(),
  442. 'form.biddingDate':this.getNewDate(),
  443. })
  444. //获取资产类别
  445. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_type', {method:'GET'}, {
  446. success: (res) => {
  447. if(res.data.length>0){
  448. that.setData({
  449. assetTypeOptions:res.data,
  450. 'form.assetType':res.data[0].dictValue
  451. })
  452. }
  453. }
  454. })
  455. //获取经营属性
  456. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'operation_type', {method:'GET'}, {
  457. success: (res) => {
  458. if(res.data.length>0){
  459. that.setData({
  460. operationTypeOptions:res.data,
  461. 'form.operationType':res.data[0].dictValue
  462. })
  463. }
  464. }
  465. })
  466. //获取增加方式
  467. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'add_type', {method:'GET'}, {
  468. success: (res) => {
  469. if(res.data.length>0){
  470. that.setData({
  471. addTypeOptions:res.data,
  472. 'form.addType':res.data[0].dictValue
  473. })
  474. }
  475. }
  476. })
  477. //获取使用情况
  478. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'use_type', {method:'GET'}, {
  479. success: (res) => {
  480. if(res.data.length>0){
  481. that.setData({
  482. useTypeOptions:res.data,
  483. 'form.useType':res.data[0].dictValue
  484. })
  485. }
  486. }
  487. })
  488. //获取折旧方式
  489. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'depreciation_type', {method:'GET'}, {
  490. success: (res) => {
  491. if(res.data.length>0){
  492. that.setData({
  493. depreciationTypeOptions:res.data,
  494. 'form.depreciationType':res.data[1].dictValue
  495. })
  496. }
  497. }
  498. })
  499. //获取资产状态
  500. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_status', {method:'GET'}, {
  501. success: (res) => {
  502. if(res.data.length>0){
  503. that.setData({
  504. assetStatusOptions:res.data,
  505. 'form.assetStatusOptions':res.data[0].dictValue
  506. })
  507. }
  508. }
  509. })
  510. //获取单位
  511. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'fixed_assets_unit', {method:'GET'}, {
  512. success: (res) => {
  513. if(res.data.length>0){
  514. that.setData({
  515. unitOptions:res.data,
  516. 'form.unit':res.data[0].dictValue
  517. })
  518. }
  519. }
  520. })
  521. //获取是否
  522. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'sys_yes_no', {method:'GET'}, {
  523. success: (res) => {
  524. if(res.data.length>0){
  525. that.setData({
  526. sysYesNoOptions:res.data,
  527. 'form.isMin':res.data[0].dictValue,
  528. 'form.isFormAsset':res.data[0].dictValue
  529. })
  530. }
  531. }
  532. })
  533. }
  534. },
  535. /**
  536. * 生命周期函数--监听页面初次渲染完成
  537. */
  538. onReady() {
  539. },
  540. /**
  541. * 生命周期函数--监听页面显示
  542. */
  543. onShow() {
  544. },
  545. /**
  546. * 生命周期函数--监听页面隐藏
  547. */
  548. onHide() {
  549. },
  550. /**
  551. * 生命周期函数--监听页面卸载
  552. */
  553. onUnload() {
  554. },
  555. /**
  556. * 页面相关事件处理函数--监听用户下拉动作
  557. */
  558. onPullDownRefresh() {
  559. },
  560. /**
  561. * 页面上拉触底事件的处理函数
  562. */
  563. onReachBottom() {
  564. },
  565. /**
  566. * 用户点击右上角分享
  567. */
  568. onShareAppMessage() {
  569. }
  570. })