微信小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

fixedAssets.js 11 KiB

3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. // pages/bank/bank.js
  2. import * as UTIL from '../../utils/util.js';
  3. import * as API from '../../utils/API.js';
  4. let EVN_CONFIG = require('../../env/env');
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. isIPX: app.globalData.isIPX,
  12. list:[],
  13. list1:[],
  14. isLoading:false,
  15. pageNums:1,
  16. scrollHeight:"",
  17. name:"",
  18. showUpload:false,
  19. uploadOptions:[],
  20. fileList:[],
  21. showPopup:false,
  22. fileEvent:{},
  23. itemId:"",
  24. assetTypeOptions:[],
  25. status:0,
  26. index:0,
  27. array:[
  28. {assetTable:'t_asset_permanent',assetTableName:'固定资产'},
  29. {assetTable:'t_asset_resource',assetTableName:'资源性资产'}
  30. ],
  31. },
  32. goAdd(){
  33. wx.navigateTo({
  34. url: 'add/add',
  35. })
  36. },
  37. back:function(){
  38. wx.navigateBack({
  39. delta: 1
  40. })
  41. },
  42. assetTypeDict(val){
  43. this.data.assetTypeOptions.map(res => {
  44. if(res.dictValue == val){
  45. return res.dictLabel
  46. }
  47. })
  48. },
  49. bindPickerChange:function(e){
  50. this.setData({index:e.detail.value});
  51. this.getList()
  52. },
  53. /**
  54. * 生命周期函数--监听页面加载
  55. */
  56. onLoad(options) {
  57. var that = this;
  58. let qu = wx.createSelectorQuery()
  59. qu.select("#top_view").boundingClientRect()
  60. qu.select("#top_ban").boundingClientRect()
  61. qu.exec(res => {
  62. that.setData({
  63. scrollHeight:wx.getSystemInfoSync().windowHeight-res[0].height-res[0].top
  64. })
  65. })
  66. this.setData({'itemId':options.id})
  67. },
  68. /**
  69. * 生命周期函数--监听页面初次渲染完成
  70. */
  71. onReady() {
  72. //获取附件字典
  73. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'common_attach', {method:'GET'}, {
  74. success: (res) => {
  75. if(res.data.length>0){
  76. this.setData({
  77. uploadOptions:res.data,
  78. })
  79. }
  80. }
  81. })
  82. this.getList();
  83. },
  84. getList:function(){
  85. if(this.data.index == 0){
  86. let params = {
  87. name:this.data.name,
  88. useType:'2',
  89. OperationType:'1',
  90. assetStatus:'1',
  91. isMin:'Y'
  92. }
  93. UTIL.httpRequest(API.URL_GET_PERMANENTLIST,params,{
  94. success: (res) => {
  95. let _this = this
  96. if(res.code == 200){
  97. //获取资产类别
  98. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_type', {method:'GET'}, {
  99. success: (r) => {
  100. if(r.data.length>0){
  101. let li = res.rows.map( ress => {
  102. r.data.map(rr => {
  103. if(ress.assetType == rr.dictValue){
  104. ress.assetType = rr.dictLabel
  105. }
  106. })
  107. return ress
  108. })
  109. _this.setData({list:li})
  110. }else{
  111. _this.setData({list:res.rows})
  112. }
  113. }
  114. })
  115. }else{
  116. UTIL.showToastNoneIcon(res.msg);
  117. }
  118. }
  119. })
  120. }else{
  121. let params = {
  122. name:this.data.name,
  123. useType : '2',
  124. status : '0'
  125. }
  126. UTIL.httpRequest(API.URL_GET_RESOURCELIST,params,{
  127. success: (res) => {
  128. let _this = this
  129. if(res.code == 200){
  130. //获取资产类别
  131. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'resource_type', {method:'GET'}, {
  132. success: (r) => {
  133. if(r.data.length>0){
  134. let li = res.rows.map( ress => {
  135. r.data.map(rr => {
  136. if(ress.resourceType == rr.dictValue){
  137. ress.resourceType = rr.dictLabel
  138. }
  139. })
  140. return ress
  141. })
  142. _this.setData({list1:li})
  143. }else{
  144. _this.setData({list1:res.rows})
  145. }
  146. }
  147. })
  148. }else{
  149. UTIL.showToastNoneIcon(res.msg);
  150. }
  151. }
  152. })
  153. }
  154. },
  155. paging(){
  156. this.setData({
  157. pageNums:this.data.pageNums+1,
  158. })
  159. this.getList();
  160. },
  161. goSearch(e){
  162. this.setData({name:e.detail});
  163. this.setData({pageNums:1});
  164. this.getList();
  165. },
  166. goUpdate(e){
  167. if(this.data.status=='0'){
  168. this.setData({'status':1})
  169. let data = e.currentTarget.dataset.item;
  170. data.method = "POST";
  171. data.assetTable = 't_asset_permanent'
  172. data.assetId = e.currentTarget.dataset.item.id
  173. data.contractionId = this.data.itemId
  174. data.num = e.currentTarget.dataset.item.quantity
  175. if(data.unit==""||data.unit==null){
  176. data.unit = '台'
  177. }
  178. UTIL.httpRequest(API.URL_GET_ASSETADD,data,{
  179. success: (res) => {
  180. if(res.code == 200){
  181. UTIL.showToastNoneIcon(res.msg);
  182. this.setData({'status':0})
  183. wx.navigateBack({
  184. delta: 1
  185. })
  186. }else{
  187. UTIL.showToastNoneIcon(res.msg);
  188. this.setData({'status':0})
  189. }
  190. }
  191. })
  192. }
  193. },
  194. goUpdate1(e){
  195. if(this.data.status=='0'){
  196. this.setData({'status':1})
  197. let data = e.currentTarget.dataset.item;
  198. data.method = "POST";
  199. data.assetTable = 't_asset_resource'
  200. data.assetId = e.currentTarget.dataset.item.id
  201. data.contractionId = this.data.itemId
  202. data.num = e.currentTarget.dataset.item.totalArea
  203. if(data.unit==""||data.unit==null){
  204. data.unit = '亩'
  205. }
  206. UTIL.httpRequest(API.URL_GET_ASSETADD,data,{
  207. success: (res) => {
  208. if(res.code == 200){
  209. UTIL.showToastNoneIcon(res.msg);
  210. this.setData({'status':0})
  211. wx.navigateBack({
  212. delta: 1
  213. })
  214. }else{
  215. UTIL.showToastNoneIcon(res.msg);
  216. this.setData({'status':0})
  217. }
  218. }
  219. })
  220. }
  221. },
  222. delete(e){
  223. UTIL.httpRequest(API.URL_GET_PERMANENTDELETE + e.currentTarget.dataset.id, {method:'GET'}, {
  224. success: (res) => {
  225. if(res.code==200){
  226. let new_list = this.data.list
  227. new_list.splice(e.currentTarget.dataset.index,1)
  228. this.setData({'list':new_list})
  229. UTIL.showToastNoneIcon('删除成功!');
  230. }else{
  231. UTIL.showToastNoneIcon('删除失败!');
  232. }
  233. }
  234. })
  235. },
  236. upload(e){
  237. this.setData({itemId:e.currentTarget.dataset.id});
  238. this.asyncFun(e.currentTarget.dataset.id)
  239. },
  240. asyncFun(id){
  241. this.setData({"fileList":[]})
  242. let uploadList = this.data.uploadOptions
  243. let newList = []
  244. let _this = this
  245. uploadList.map( res => {
  246. let oData = {
  247. tableId: id,
  248. tableName: "t_asset_permanent", //上传表
  249. bizPath: "asset",
  250. fileType: res.dictValue, //附件类型 1原始发票 2会议纪要 3会议照片 4 参会人员签字
  251. method:'GET'
  252. }
  253. UTIL.httpRequest(API.URL_GET_ATTACHMENTLIST, oData, {
  254. success: (rr) => {
  255. if(rr.rows.length>0){
  256. rr.rows.map((rrr,index) => {
  257. rrr.url = wx.getStorageSync('dressCode') + rrr.fileUrl
  258. if(index==rr.rows.length-1){
  259. newList.push(Object.assign({},res,{"list":rr.rows}))
  260. _this.setData({"fileList":_this.data.fileList.concat(newList)});
  261. _this.setData({"showUpload":true})
  262. }
  263. })
  264. }else{
  265. let newuploadList = uploadList
  266. newuploadList.map(rd => {
  267. rd.list = newList
  268. })
  269. _this.setData({"fileList":newuploadList});
  270. _this.setData({"showUpload":true})
  271. }
  272. }
  273. })
  274. })
  275. },
  276. closeBox(){
  277. this.setData({"showUpload":false})
  278. },
  279. deleteImg(event){
  280. this.setData({"fileEvent":event})
  281. this.setData({"showPopup":true});
  282. },
  283. cancelTem:function(e){
  284. this.setData({"fileEvent":"{}"});
  285. this.setData({"showPopup":false});
  286. },
  287. confirmTem:function(e){
  288. let event = this.data.fileEvent
  289. UTIL.httpRequest(API.URL_GET_GETFILEREMOVE+event.detail.file.id , {method:'GET'}, {
  290. success: (res) => {
  291. if(res.code==200){
  292. let ll = this.data.fileList
  293. var jsonlist = ll[event.target.dataset.idx].list;
  294. jsonlist.splice(event.detail.index, 1)
  295. ll[event.target.dataset.idx].list = jsonlist
  296. this.setData({"fileList":ll})
  297. this.setData({showPopup:false});
  298. wx.showToast({
  299. title: '删除成功!',
  300. icon: 'success',
  301. duration: 2000,
  302. })
  303. }
  304. }
  305. })
  306. },
  307. uploadFile(uploadFile,event) {
  308. let _this = this
  309. return new Promise((resolve, reject) => {
  310. wx.uploadFile({
  311. url: API.URL_GET_UPLOAD,
  312. filePath: uploadFile.file.file[0].url,
  313. name: 'file',
  314. header: {
  315. "Content-Type": "multipart/form-data",//记得设置
  316. "chartset":"utf-8",
  317. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  318. },
  319. formData:uploadFile,
  320. success: (res) => {
  321. res.data = JSON.parse(res.data);
  322. if(res.statusCode == 200){
  323. let files = _this.data.fileList
  324. let fName = res.data.fileUrl.split('/')
  325. let fLength = fName.length
  326. files[event.currentTarget.dataset.idx].list.push({
  327. "fileName": fName[fLength-1],
  328. "fileType": "0",
  329. "fileUrl":res.data.fileUrl ,
  330. "id": res.data.id,
  331. "tableId": 6,
  332. "url":wx.getStorageSync('dressCode')+res.data.fileUrl
  333. })
  334. _this.setData({"fileList":files})
  335. wx.hideLoading()
  336. }
  337. },
  338. fail: (err) => {
  339. //上传失败:修改pedding为reject
  340. reject(err)
  341. }
  342. });
  343. })
  344. },
  345. afterRead(event) {
  346. let _this = this
  347. wx.showLoading({
  348. title: '上传中...'
  349. })
  350. let fileForm={
  351. file: event.detail,
  352. fileType:event.currentTarget.dataset.idx,
  353. tableName: "t_asset_permanent", //上传表
  354. bizPath: "asset",
  355. tableId:_this.data.itemId
  356. }
  357. this.uploadFile(fileForm,event)
  358. },
  359. lookDown(file,detail){
  360. // 获取指定字符串最后一次出现的位置,返回index
  361. var index1 = file.detail.url.lastIndexOf('.');
  362. // substr(start, length) 抽取从start下标开始的length个字符,返回新的字符串;
  363. var style = file.detail.url.substr(index1 + 1)
  364. //判断图片类型,不需要下载,不做处理
  365. if(style=='png'||style=='jpg'||style=='jpeg'||style=='bmp'||style=='gif'||style=='webp'||style=='psd'||style== 'svg'||style=='tiff'){
  366. //判断非图片类型
  367. }else{
  368. wx.downloadFile({
  369. url: file.detail.url,
  370. success(data){
  371. wx.openDocument({
  372. filePath: data.tempFilePath,
  373. fileType: style,
  374. showMenu:true,
  375. success(res){
  376. }
  377. })
  378. }
  379. })
  380. }
  381. },
  382. /**
  383. * 生命周期函数--监听页面显示
  384. */
  385. onShow() {
  386. },
  387. /**
  388. * 生命周期函数--监听页面隐藏
  389. */
  390. onHide() {
  391. },
  392. /**
  393. * 生命周期函数--监听页面卸载
  394. */
  395. onUnload() {
  396. },
  397. /**
  398. * 页面相关事件处理函数--监听用户下拉动作
  399. */
  400. onPullDownRefresh() {
  401. },
  402. /**
  403. * 页面上拉触底事件的处理函数
  404. */
  405. onReachBottom() {
  406. },
  407. /**
  408. * 用户点击右上角分享
  409. */
  410. onShareAppMessage() {
  411. }
  412. })