微信小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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. },
  19. assetTypeindex:'0',
  20. settleTypeindex:'0',
  21. collectionPayindex:'0',
  22. contractionSourceindex:'0',
  23. contractionStatusindex:'0',
  24. biddingWayindex:'0',
  25. biddingTypeindex:'0',
  26. showBiddingDate:false,
  27. minDate: new Date(2008, 5, 1).getTime(),
  28. maxDate: new Date(2040, 0, 31).getTime(),
  29. // 合同类型字典
  30. assetTypeOptions: [],
  31. // 结款方式字典
  32. settleTypeOptions: [],
  33. // 收付款类型字典
  34. collectionPayOptions: [],
  35. // 合同来源字典
  36. contractionSourceOptions: [],
  37. // 合同状态字典
  38. contractionStatusOptions: [],
  39. // 招标方式字典
  40. biddingWayOptions: [],
  41. // 招标类型字典
  42. biddingTypeOptions: [],
  43. status:0,
  44. },
  45. back:function(){
  46. wx.navigateBack({
  47. delta: 1
  48. })
  49. },
  50. openBox(even){
  51. this.setData({
  52. [even.currentTarget.dataset.name]:true
  53. })
  54. },
  55. onChange(event){
  56. this.setData({
  57. [event.currentTarget.dataset.formname]: event.detail,
  58. })
  59. },
  60. closeBox(even){
  61. this.setData({
  62. [even.currentTarget.dataset.name]:false
  63. })
  64. },
  65. onConfirmBiddingDate(e){
  66. let data = this.getNewDate(new Date(e.detail.value));
  67. this.setData({'form.biddingDate':data});
  68. },
  69. onConfirmReviewTime(e){
  70. let data = this.getNewDate(new Date(e.detail.value));
  71. this.setData({'form.reviewTime':data});
  72. },
  73. onConfirmBuildingTime(e){
  74. let data = this.getNewDate(new Date(e.detail.value));
  75. this.setData({'form.buildingTime':data});
  76. },
  77. onConfirmStartTime(e){
  78. let data = this.getNewDate(new Date(e.detail.value));
  79. this.setData({'form.startTime':data});
  80. },
  81. onConfirmEndTime(e){
  82. let data = this.getNewDate(new Date(e.detail.value));
  83. this.setData({'form.endTime':data});
  84. },
  85. onConfirmbiddingType (e) {
  86. let obj = e.detail.value;
  87. this.setData({
  88. 'form.biddingType':this.data.biddingTypeOptions[obj].dictValue,
  89. 'biddingTypeindex':obj
  90. })
  91. },
  92. onConfirmShowBiddingWay (e) {
  93. let obj = e.detail.value;
  94. this.setData({
  95. 'form.biddingWay':this.data.biddingWayOptions[obj].dictValue,
  96. 'biddingWayindex':obj
  97. })
  98. },
  99. onConfirmSettleType (e) {
  100. let obj = e.detail.value;
  101. this.setData({
  102. 'form.settleType':this.data.settleTypeOptions[obj].dictValue,
  103. 'settleTypeindex':obj
  104. })
  105. },
  106. onConfirmCollectionPay (e) {
  107. let obj = e.detail.value;
  108. this.setData({
  109. 'form.collectionPay':this.data.collectionPayOptions[obj].dictValue,
  110. 'collectionPayindex':obj
  111. })
  112. },
  113. onConfirmContractionSource (e) {
  114. let obj = e.detail.value;
  115. this.setData({
  116. 'form.contractionSource':this.data.contractionSourceOptions[obj].dictValue,
  117. 'contractionSourceindex':obj
  118. })
  119. },
  120. onConfirmAssetType (e) {
  121. let obj = e.detail.value;
  122. this.setData({
  123. 'form.assetType':this.data.assetTypeOptions[obj].dictValue,
  124. 'assetTypeindex':obj
  125. })
  126. },
  127. onConfirmContractionStatus (e) {
  128. let obj = e.detail.value;
  129. this.setData({
  130. 'form.contractionStatus':this.data.contractionStatusOptions[obj].dictValue,
  131. 'contractionStatusindex':obj
  132. })
  133. },
  134. onConfirmBiddingWay (e) {
  135. let obj = e.detail.value;
  136. this.setData({
  137. 'form.biddingWay':this.data.biddingWayOptions[obj].dictValue,
  138. 'biddingWayindex':obj
  139. })
  140. },
  141. getNewDate(date){
  142. //date是传过来的时间戳,注意需为13位,10位需*1000
  143. //也可以不传,获取的就是当前时间
  144. var time
  145. if(date){
  146. time = new Date(date);
  147. }else{
  148. time = new Date();
  149. }
  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.firstParty===''||this.data.form.firstParty==null){ //甲方
  164. UTIL.showToastNoneIcon('请输入甲方名称!');
  165. return false;
  166. }else if(this.data.form.secondParty===''||this.data.form.secondParty==null){ //乙方
  167. UTIL.showToastNoneIcon('请输入乙方名称!');
  168. return false;
  169. }else if(this.data.form.collectionPay === ''||this.data.form.collectionPay==null){//收付款类型
  170. UTIL.showToastNoneIcon('收付款类型不能为空!');
  171. return false;
  172. }else if(this.data.form.contractionSource === ''||this.data.form.contractionSource==null){//合同来源
  173. UTIL.showToastNoneIcon('合同来源不能为空!');
  174. return false;
  175. }else if(this.data.form.totalAmount === ''||this.data.form.totalAmount==null){//合同金额
  176. UTIL.showToastNoneIcon('合同金额不能为空!');
  177. return false;
  178. }else if(this.data.form.buildingTime === ''||this.data.form.buildingTime==null){//签订日期
  179. UTIL.showToastNoneIcon('签订日期不能为空!');
  180. return false;
  181. }else if(this.data.form.startTime === ''||this.data.form.startTime==null){//开始日期
  182. UTIL.showToastNoneIcon('开始日期不能为空!');
  183. return false;
  184. }else if(this.data.form.endTime === ''||this.data.form.endTime==null){//结束日期
  185. UTIL.showToastNoneIcon('结束日期不能为空!');
  186. return false;
  187. }else if(this.data.form.price === ''||this.data.form.price==null){//单价
  188. UTIL.showToastNoneIcon('单价不能为空!');
  189. return false;
  190. }else if(this.data.form.receivedAmount === ''||this.data.form.receivedAmount==null){//已结款
  191. UTIL.showToastNoneIcon('已结款不能为空!');
  192. return false;
  193. }else if(this.data.form.contractionStatus === ''||this.data.form.contractionStatus==null){//合同状态
  194. UTIL.showToastNoneIcon('合同状态不能为空!');
  195. return false;
  196. }else if(this.data.status=='0'){
  197. this.setData({'status':1})
  198. if(this.data.form.id!=null&&this.data.form.id!=""){
  199. let data = this.data.form;
  200. data.method = "POST";
  201. UTIL.httpRequest(API.URL_POST_CONTRACTUPDATE,data,{
  202. success: (res) => {
  203. this.setData({'status':0})
  204. if(res.code == 200){
  205. UTIL.showToastNoneIcon('修改成功');
  206. setTimeout(function(){
  207. wx.navigateBack({
  208. delta:1
  209. })
  210. },2000)
  211. }else{
  212. UTIL.showToastNoneIcon('修改失败:'+res.msg);
  213. }
  214. },
  215. fail: function (response) {
  216. if (typeof fail === FUNCTION_TEXT) {
  217. fail(handleFail(response));
  218. } else {
  219. showToastNoneIcon(API.MSG_FAIL_HTTP);
  220. }
  221. this.setData({'status':0})
  222. },
  223. complete: function (response) {
  224. wx.hideNavigationBarLoading();
  225. }
  226. })
  227. }else{
  228. let data = this.data.form;
  229. data.method = "POST";
  230. UTIL.httpRequest(API.URL_POST_CONTRACTADD,data,{
  231. success: (res) => {
  232. this.setData({'status':0})
  233. if(res.code == 200){
  234. UTIL.showToastNoneIcon('新增成功');
  235. setTimeout(function(){
  236. wx.navigateBack({
  237. delta:1
  238. })
  239. },2000)
  240. }else{
  241. UTIL.showToastNoneIcon('新增失败:'+res.msg);
  242. }
  243. },
  244. fail: function (response) {
  245. if (typeof fail === FUNCTION_TEXT) {
  246. fail(handleFail(response));
  247. } else {
  248. showToastNoneIcon(API.MSG_FAIL_HTTP);
  249. }
  250. },
  251. complete: function (response) {
  252. wx.hideNavigationBarLoading();
  253. }
  254. })
  255. }
  256. }
  257. },
  258. bindNewInput: function (e) {
  259. this.setData({
  260. [e.currentTarget.dataset.name]: e.detail.value
  261. })
  262. },
  263. /**
  264. * 生命周期函数--监听页面加载
  265. */
  266. onLoad(options) {
  267. if(options.id!=null&&options.id!=""){
  268. this.setData({id:options.id})
  269. //获取收入合同状态
  270. UTIL.httpRequest(API.URL_GET_CONTRACTDETAIL + this.data.id, {method:'GET'}, {
  271. success: (res) => {
  272. this.setData({'form':res.data});
  273. let that = this;
  274. //获取收入合同状态
  275. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'type_of_contract', {method:'GET'}, {
  276. success: (r) => {
  277. if(r.data.length>0){
  278. that.setData({
  279. assetTypeOptions:r.data,
  280. })
  281. r.data.map((rr,ind) => {
  282. if(rr.dictValue == res.data.assetType){
  283. that.setData({'assetTypeindex':ind})
  284. }
  285. })
  286. }
  287. }
  288. })
  289. //获取收入合同来源
  290. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'contraction_source', {method:'GET'}, {
  291. success: (r) => {
  292. if(r.data.length>0){
  293. that.setData({
  294. contractionSourceOptions:r.data,
  295. })
  296. r.data.map((rr,ind) => {
  297. if(rr.dictValue == res.data.contractionSource){
  298. that.setData({'contractionSourceindex':ind})
  299. }
  300. })
  301. }
  302. }
  303. })
  304. //获取收入收付款类型
  305. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'collection_pay', {method:'GET'}, {
  306. success: (r) => {
  307. if(r.data.length>0){
  308. that.setData({
  309. collectionPayOptions:r.data,
  310. })
  311. r.data.map((rr,ind) => {
  312. if(rr.dictValue == res.data.collectionPay){
  313. that.setData({'collectionPayindex':ind})
  314. }
  315. })
  316. }
  317. }
  318. })
  319. //获取收入结款方式
  320. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'settle_type', {method:'GET'}, {
  321. success: (r) => {
  322. if(r.data.length>0){
  323. that.setData({
  324. settleTypeOptions:r.data,
  325. })
  326. r.data.map((rr,ind) => {
  327. if(rr.dictValue == res.data.settleType){
  328. that.setData({'settleTypeindex':ind})
  329. }
  330. })
  331. }
  332. }
  333. })
  334. //获取收入合同状态
  335. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'contraction_status', {method:'GET'}, {
  336. success: (r) => {
  337. if(r.data.length>0){
  338. that.setData({
  339. contractionStatusOptions:r.data,
  340. })
  341. r.data.map((rr,ind) => {
  342. if(rr.dictValue == res.data.contractionStatus){
  343. that.setData({'contractionStatusindex':ind})
  344. }
  345. })
  346. }
  347. }
  348. })
  349. //获取收入招标方式
  350. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bidding_way', {method:'GET'}, {
  351. success: (r) => {
  352. if(r.data.length>0){
  353. that.setData({
  354. biddingWayOptions:r.data,
  355. })
  356. r.data.map((rr,ind) => {
  357. if(rr.dictValue == res.data.biddingWay){
  358. that.setData({'biddingWayindex':ind})
  359. }
  360. })
  361. }
  362. }
  363. })
  364. //获取收入招标类型
  365. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bidding_types', {method:'GET'}, {
  366. success: (r) => {
  367. if(r.data.length>0){
  368. that.setData({
  369. biddingTypeOptions:r.data,
  370. })
  371. r.data.map((rr,ind) => {
  372. if(rr.dictValue == res.data.biddingType){
  373. that.setData({'biddingTypeindex':ind})
  374. }
  375. })
  376. }
  377. }
  378. })
  379. }
  380. })
  381. }else{
  382. let that = this;
  383. this.setData({
  384. 'form.reviewTime':this.getNewDate(),
  385. 'form.buildingTime':this.getNewDate(),
  386. 'form.startTime':this.getNewDate(),
  387. 'form.endTime':this.getNewDate(),
  388. 'form.biddingDate':this.getNewDate(),
  389. })
  390. //获取收入合同状态
  391. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'type_of_contract', {method:'GET'}, {
  392. success: (res) => {
  393. if(res.data.length>0){
  394. that.setData({
  395. assetTypeOptions:res.data,
  396. 'form.assetType':res.data[0].dictValue
  397. })
  398. }
  399. }
  400. })
  401. //获取收入合同来源
  402. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'contraction_source', {method:'GET'}, {
  403. success: (res) => {
  404. if(res.data.length>0){
  405. that.setData({
  406. contractionSourceOptions:res.data,
  407. 'form.contractionSource':res.data[0].dictValue
  408. })
  409. }
  410. }
  411. })
  412. //获取收入收付款类型
  413. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'collection_pay', {method:'GET'}, {
  414. success: (res) => {
  415. if(res.data.length>0){
  416. that.setData({
  417. collectionPayOptions:res.data,
  418. 'form.collectionPay':res.data[0].dictValue
  419. })
  420. }
  421. }
  422. })
  423. //获取收入结款方式
  424. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'settle_type', {method:'GET'}, {
  425. success: (res) => {
  426. if(res.data.length>0){
  427. that.setData({
  428. settleTypeOptions:res.data,
  429. 'form.settleType':res.data[0].dictValue
  430. })
  431. }
  432. }
  433. })
  434. //获取收入合同状态
  435. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'contraction_status', {method:'GET'}, {
  436. success: (res) => {
  437. if(res.data.length>0){
  438. that.setData({
  439. contractionStatusOptions:res.data,
  440. 'form.contractionStatus':res.data[0].dictValue
  441. })
  442. }
  443. }
  444. })
  445. //获取收入招标方式
  446. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bidding_way', {method:'GET'}, {
  447. success: (res) => {
  448. if(res.data.length>0){
  449. that.setData({
  450. biddingWayOptions:res.data,
  451. 'form.biddingWay':res.data[0].dictValue
  452. })
  453. }
  454. }
  455. })
  456. //获取收入招标类型
  457. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bidding_types', {method:'GET'}, {
  458. success: (res) => {
  459. if(res.data.length>0){
  460. that.setData({
  461. biddingTypeOptions:res.data,
  462. 'form.biddingType':res.data[0].dictValue
  463. })
  464. }
  465. }
  466. })
  467. }
  468. },
  469. /**
  470. * 生命周期函数--监听页面初次渲染完成
  471. */
  472. onReady() {
  473. },
  474. /**
  475. * 生命周期函数--监听页面显示
  476. */
  477. onShow() {
  478. },
  479. /**
  480. * 生命周期函数--监听页面隐藏
  481. */
  482. onHide() {
  483. },
  484. /**
  485. * 生命周期函数--监听页面卸载
  486. */
  487. onUnload() {
  488. },
  489. /**
  490. * 页面相关事件处理函数--监听用户下拉动作
  491. */
  492. onPullDownRefresh() {
  493. },
  494. /**
  495. * 页面上拉触底事件的处理函数
  496. */
  497. onReachBottom() {
  498. },
  499. /**
  500. * 用户点击右上角分享
  501. */
  502. onShareAppMessage() {
  503. }
  504. })