微信小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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