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