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