微信小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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. let that = this
  204. this.setData({'status':'1'})
  205. if(this.data.form.id!=null&&this.data.form.id!=""){
  206. let data = this.data.form;
  207. data.method = "POST";
  208. UTIL.httpRequest(API.URL_POST_PERMANENTUPDATE,data,{
  209. success: (res) => {
  210. if(res.code == 200){
  211. UTIL.showToastNoneIcon('修改成功');
  212. setTimeout(function(){
  213. wx.navigateBack({
  214. delta:1
  215. })
  216. },2000)
  217. }else{
  218. UTIL.showToastNoneIcon('修改失败');
  219. that.setData({'status':'0'})
  220. }
  221. },
  222. fail: function (response) {
  223. if (typeof fail === FUNCTION_TEXT) {
  224. fail(handleFail(response));
  225. } else {
  226. showToastNoneIcon(API.MSG_FAIL_HTTP);
  227. }
  228. that.setData({'status':0})
  229. },
  230. complete: function (response) {
  231. that.setData({'status':0})
  232. wx.hideNavigationBarLoading();
  233. }
  234. })
  235. }else{
  236. let data = this.data.form;
  237. data.method = "POST";
  238. UTIL.httpRequest(API.URL_POST_PERMANENTADD,data,{
  239. success: (res) => {
  240. if(res.code == 200){
  241. UTIL.showToastNoneIcon(res.msg);
  242. setTimeout(function(){
  243. wx.navigateBack({
  244. delta:1
  245. })
  246. },2000)
  247. }else{
  248. UTIL.showToastNoneIcon(res.msg);
  249. that.setData({'status':'0'})
  250. }
  251. },
  252. fail: function (response) {
  253. if (typeof fail === FUNCTION_TEXT) {
  254. fail(handleFail(response));
  255. } else {
  256. showToastNoneIcon(API.MSG_FAIL_HTTP);
  257. }
  258. that.setData({'status':0})
  259. },
  260. complete: function (response) {
  261. that.setData({'status':0})
  262. wx.hideNavigationBarLoading();
  263. }
  264. })
  265. }
  266. }
  267. },
  268. bindNewInput: function (e) {
  269. this.setData({
  270. [e.currentTarget.dataset.name]: e.detail.value
  271. })
  272. if(e.currentTarget.dataset.name == 'form.originalValue' ){
  273. this.setData({
  274. 'form.netSalvage' : (this.data.form.residualsRate*e.detail.value/100).toFixed(2),
  275. 'form.perYearDepreciationValue' : ((e.detail.value-(this.data.form.residualsRate*e.detail.value/100))/this.data.form.expectedYears).toFixed(2),
  276. 'form.netValue':this.data.form.originalValue-this.data.form.depreciationValue
  277. })
  278. }
  279. if(e.currentTarget.dataset.name == 'form.residualsRate' &&e.detail.value<=100){
  280. this.setData({
  281. 'form.netSalvage' : (this.data.form.originalValue*e.detail.value/100)<this.data.form.originalValue?(this.data.form.originalValue*e.detail.value/100).toFixed(2):this.data.form.originalValue,
  282. })
  283. this.setData({
  284. 'form.perYearDepreciationValue' : ((this.data.form.originalValue-this.data.form.netSalvage)/this.data.form.expectedYears).toFixed(2),
  285. })
  286. }
  287. if(e.currentTarget.dataset.name == 'form.residualsRate' &&e.detail.value>100){
  288. this.setData({
  289. 'form.residualsRate' : 5,
  290. })
  291. }
  292. if(e.currentTarget.dataset.name == 'form.netSalvage' ){
  293. this.setData({
  294. 'form.perYearDepreciationValue' : ((this.data.form.originalValue-e.detail.value)/this.data.form.expectedYears).toFixed(2)
  295. })
  296. }
  297. if(e.currentTarget.dataset.name == 'form.expectedYears' ){
  298. this.setData({
  299. 'form.perYearDepreciationValue' : ((this.data.form.originalValue-this.data.form.netSalvage)/e.detail.value).toFixed(2)
  300. })
  301. }
  302. if(e.currentTarget.dataset.name == 'form.depreciationYears' ){
  303. this.setData({
  304. 'form.depreciationValue' : (this.data.form.perYearDepreciationValue*e.detail.value)>this.data.form.originalValue?this.data.form.originalValue:(this.data.form.perYearDepreciationValue*e.detail.value).toFixed(2),
  305. 'form.netValue' : (this.data.form.originalValue-(this.data.form.perYearDepreciationValue*e.detail.value))>=0?(this.data.form.originalValue-(this.data.form.perYearDepreciationValue*e.detail.value).toFixed(2)):0
  306. })
  307. }
  308. },
  309. /**
  310. * 生命周期函数--监听页面加载
  311. */
  312. onLoad(options) {
  313. if(options.id!=null&&options.id!=""){
  314. this.setData({id:options.id})
  315. //获取收入合同状态
  316. UTIL.httpRequest(API.URL_GET_PERMANENTDETAIL + this.data.id, {method:'GET'}, {
  317. success: (res) => {
  318. this.setData({'form':res.data});
  319. let that = this;
  320. //获取资产类别
  321. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_type', {method:'GET'}, {
  322. success: (r) => {
  323. if(r.data.length>0){
  324. that.setData({
  325. assetTypeOptions:r.data,
  326. })
  327. r.data.map((rr,ind) => {
  328. if(rr.dictValue == res.data.assetType){
  329. that.setData({'assetTypeindex':ind})
  330. }
  331. })
  332. }
  333. }
  334. })
  335. //获取经营属性
  336. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'operation_type', {method:'GET'}, {
  337. success: (r) => {
  338. if(r.data.length>0){
  339. that.setData({
  340. operationTypeOptions:r.data,
  341. })
  342. r.data.map((rr,ind) => {
  343. if(rr.dictValue == res.data.operationType){
  344. that.setData({'operationTypeindex':ind})
  345. }
  346. })
  347. }
  348. }
  349. })
  350. //获取增加方式
  351. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'add_type', {method:'GET'}, {
  352. success: (r) => {
  353. if(r.data.length>0){
  354. that.setData({
  355. addTypeOptions:r.data,
  356. })
  357. r.data.map((rr,ind) => {
  358. if(rr.dictValue == res.data.addType){
  359. that.setData({'addTypeindex':ind})
  360. }
  361. })
  362. }
  363. }
  364. })
  365. //获取使用情况
  366. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'use_type', {method:'GET'}, {
  367. success: (r) => {
  368. if(r.data.length>0){
  369. that.setData({
  370. useTypeOptions:r.data,
  371. })
  372. r.data.map((rr,ind) => {
  373. if(rr.dictValue == res.data.useType){
  374. that.setData({'useTypeindex':ind})
  375. }
  376. })
  377. }
  378. }
  379. })
  380. //获取折旧方式
  381. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'depreciation_type', {method:'GET'}, {
  382. success: (r) => {
  383. if(r.data.length>0){
  384. that.setData({
  385. depreciationTypeOptions:r.data,
  386. })
  387. r.data.map((rr,ind) => {
  388. if(rr.dictValue == res.data.depreciationType){
  389. that.setData({'depreciationTypeindex':ind})
  390. }
  391. })
  392. }
  393. }
  394. })
  395. //获取资产状态
  396. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_status', {method:'GET'}, {
  397. success: (r) => {
  398. if(r.data.length>0){
  399. that.setData({
  400. assetStatusOptions:r.data,
  401. })
  402. r.data.map((rr,ind) => {
  403. if(rr.dictValue == res.data.assetStatus){
  404. that.setData({'assetStatusindex':ind})
  405. }
  406. })
  407. }
  408. }
  409. })
  410. //获取单位
  411. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'fixed_assets_unit', {method:'GET'}, {
  412. success: (r) => {
  413. if(r.data.length>0){
  414. that.setData({
  415. unitOptions:r.data,
  416. })
  417. r.data.map((rr,ind) => {
  418. if(rr.dictValue == res.data.unit){
  419. that.setData({'unitindex':ind})
  420. }
  421. })
  422. }
  423. }
  424. })
  425. //获取系统是否
  426. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'sys_yes_no', {method:'GET'}, {
  427. success: (r) => {
  428. if(r.data.length>0){
  429. that.setData({
  430. sysYesNoOptions:r.data,
  431. })
  432. r.data.map((rr,ind) => {
  433. if(rr.dictValue == res.data.isMin){
  434. that.setData({'isMinindex':ind})
  435. }
  436. if(rr.dictValue == res.data.isFormAsset){
  437. that.setData({'isFormAssetindex':ind})
  438. }
  439. })
  440. }
  441. }
  442. })
  443. }
  444. })
  445. }else{
  446. let that = this;
  447. this.setData({
  448. 'form.reviewTime':this.getNewDate(),
  449. 'form.buildTime':this.getNewDate(),
  450. 'form.startTime':this.getNewDate(),
  451. 'form.endTime':this.getNewDate(),
  452. 'form.biddingDate':this.getNewDate(),
  453. })
  454. //获取资产类别
  455. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_type', {method:'GET'}, {
  456. success: (res) => {
  457. if(res.data.length>0){
  458. that.setData({
  459. assetTypeOptions:res.data,
  460. 'form.assetType':res.data[0].dictValue
  461. })
  462. }
  463. }
  464. })
  465. //获取经营属性
  466. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'operation_type', {method:'GET'}, {
  467. success: (res) => {
  468. if(res.data.length>0){
  469. that.setData({
  470. operationTypeOptions:res.data,
  471. 'form.operationType':res.data[0].dictValue
  472. })
  473. }
  474. }
  475. })
  476. //获取增加方式
  477. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'add_type', {method:'GET'}, {
  478. success: (res) => {
  479. if(res.data.length>0){
  480. that.setData({
  481. addTypeOptions:res.data,
  482. 'form.addType':res.data[0].dictValue
  483. })
  484. }
  485. }
  486. })
  487. //获取使用情况
  488. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'use_type', {method:'GET'}, {
  489. success: (res) => {
  490. if(res.data.length>0){
  491. that.setData({
  492. useTypeOptions:res.data,
  493. 'form.useType':res.data[0].dictValue
  494. })
  495. }
  496. }
  497. })
  498. //获取折旧方式
  499. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'depreciation_type', {method:'GET'}, {
  500. success: (res) => {
  501. if(res.data.length>0){
  502. that.setData({
  503. depreciationTypeOptions:res.data,
  504. 'form.depreciationType':res.data[1].dictValue
  505. })
  506. }
  507. }
  508. })
  509. //获取资产状态
  510. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_status', {method:'GET'}, {
  511. success: (res) => {
  512. if(res.data.length>0){
  513. that.setData({
  514. assetStatusOptions:res.data,
  515. 'form.assetStatus':res.data[0].dictValue
  516. })
  517. }
  518. }
  519. })
  520. //获取单位
  521. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'fixed_assets_unit', {method:'GET'}, {
  522. success: (res) => {
  523. if(res.data.length>0){
  524. that.setData({
  525. unitOptions:res.data,
  526. 'form.unit':res.data[0].dictValue
  527. })
  528. }
  529. }
  530. })
  531. //获取是否
  532. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'sys_yes_no', {method:'GET'}, {
  533. success: (res) => {
  534. if(res.data.length>0){
  535. that.setData({
  536. sysYesNoOptions:res.data,
  537. 'form.isMin':res.data[0].dictValue,
  538. 'form.isFormAsset':res.data[0].dictValue
  539. })
  540. }
  541. }
  542. })
  543. }
  544. },
  545. /**
  546. * 生命周期函数--监听页面初次渲染完成
  547. */
  548. onReady() {
  549. },
  550. /**
  551. * 生命周期函数--监听页面显示
  552. */
  553. onShow() {
  554. },
  555. /**
  556. * 生命周期函数--监听页面隐藏
  557. */
  558. onHide() {
  559. },
  560. /**
  561. * 生命周期函数--监听页面卸载
  562. */
  563. onUnload() {
  564. },
  565. /**
  566. * 页面相关事件处理函数--监听用户下拉动作
  567. */
  568. onPullDownRefresh() {
  569. },
  570. /**
  571. * 页面上拉触底事件的处理函数
  572. */
  573. onReachBottom() {
  574. },
  575. /**
  576. * 用户点击右上角分享
  577. */
  578. onShareAppMessage() {
  579. }
  580. })