微信小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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