ShiList.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. // StepPage/pages/report/ShiList/ShiList.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. page_index: 1,
  8. page_size:10,
  9. items: [],
  10. itemTitle: '筛选',
  11. radio:'3',
  12. start_date:'',
  13. end_date:'',
  14. vin_no:'',
  15. active:0,
  16. steps:[],
  17. show_m:false
  18. },
  19. handleClickCheck(e){
  20. let app = getApp();
  21. let openid = app.globalData.openID;
  22. let order_no = e.currentTarget.dataset.item.order_number
  23. wx.p.request({
  24. url: `${app.globalData.url}wx/oaGetTeamDetail`,
  25. method:'POST',
  26. data:{
  27. order_no,
  28. openid
  29. }
  30. }).then(res=>{
  31. if(res.data.code==200){
  32. this.setData({
  33. show_m:true,
  34. active:res.data.data?res.data.data.length:0,
  35. steps:res.data.data.map(v=>{
  36. return {
  37. text:v.state==0?'待审核':v.state==1?'审核通过':'审核驳回',
  38. desc:'['+v.remark+']'+v.team
  39. }
  40. })
  41. })
  42. }
  43. });
  44. },
  45. handleDetail(){
  46. let item = this.data.items.filter(v=>v.is_choose);
  47. if(item.length==0){
  48. return wx.showToast({
  49. icon:'error',
  50. title: '请选择',
  51. })
  52. }else{
  53. let app = getApp();
  54. let openid = app.globalData.openID;
  55. let order_number = item[0].order_number;
  56. wx.p.request({
  57. url: `${app.globalData.url}wx/constructionDetail`,
  58. method:'POST',
  59. data:{
  60. order_number,
  61. openid
  62. }
  63. }).then(res=>{
  64. if(res.data.code==200){
  65. app.globalData.set_status = 'is_detail';
  66. app.globalData.typePage = '1';
  67. app.globalData.detailData = res.data.data;
  68. if(res.data.data.status==1){
  69. wx.p.request({
  70. url: `${app.globalData.url}wx/oaOrderState`,
  71. method:'POST',
  72. data:{
  73. menu_id:224,
  74. order_no:res.data.data.order_number,
  75. openid
  76. }
  77. }).then(req=>{
  78. if (req.data.code==200) {
  79. app.globalData.oa_state = req.data.data.state;
  80. app.globalData.oa_id = req.data.data.id
  81. }else{
  82. app.globalData.oa_state = '';
  83. app.globalData.oa_id = ''
  84. }
  85. })
  86. }else{
  87. app.globalData.oa_state = '';
  88. app.globalData.oa_id = ''
  89. }
  90. wx.p.request({
  91. url: `${app.globalData.url}wx/basicTypeList`,
  92. method:'POST',
  93. data:{ openid }
  94. }).then(req=>{
  95. app.globalData.bussiness_special_type = req.data.data.type_one.find(v=>v.id==app.globalData.detailData.basic_type_bussiness_id).special_type
  96. wx.redirectTo({
  97. url: '../../../Detail/shi/shi'
  98. })
  99. })
  100. }
  101. })
  102. }
  103. },
  104. handleDel(item){
  105. let data = item.currentTarget.dataset.item;
  106. wx.showModal({
  107. title: '确认',
  108. content: '确认删除吗?',
  109. complete: (res) => {
  110. if (res.confirm) {
  111. let app = getApp();
  112. let openid = app.globalData.openID;
  113. wx.p.request({
  114. url: `${app.globalData.url}wx/constructionDel`,
  115. method:'POST',
  116. data:{
  117. openid,
  118. order_number:[data.order_number]
  119. }
  120. }).then(res=>{
  121. if(res.data.code==200){
  122. this.initData()
  123. }
  124. wx.showToast({
  125. icon:'none',
  126. title: res.data.msg
  127. })
  128. })
  129. // constructionDel
  130. }
  131. }
  132. })
  133. },
  134. handleEdit(){
  135. let item = this.data.items.filter(v=>v.is_choose);
  136. if(item.length==0){
  137. return wx.showToast({
  138. icon:'error',
  139. title: '请选择',
  140. })
  141. }else if(item[0].status >0){
  142. return wx.showToast({
  143. icon:'error',
  144. title: '已审核不能编辑',
  145. })
  146. }else{
  147. let app = getApp();
  148. let openid = app.globalData.openID;
  149. let order_number = item[0].order_number;
  150. wx.p.request({
  151. url: `${app.globalData.url}wx/constructionDetail`,
  152. method:'POST',
  153. data:{
  154. order_number,
  155. openid
  156. }
  157. }).then(res=>{
  158. if(res.data.code==200){
  159. app.globalData.set_status = 'is_edit';
  160. app.globalData.typePage = '1';
  161. app.globalData.detailData = res.data.data;
  162. wx.p.request({
  163. url: `${app.globalData.url}wx/basicTypeList`,
  164. method:'POST',
  165. data:{ openid }
  166. }).then(req=>{
  167. app.globalData.bussiness_special_type = req.data.data.type_one.find(v=>v.id==app.globalData.detailData.basic_type_bussiness_id).special_type
  168. wx.redirectTo({
  169. url: '../../first/first',
  170. })
  171. })
  172. }
  173. })
  174. }
  175. },
  176. onChangeVinno(e){
  177. this.setData({
  178. vin_no:e.detail
  179. })
  180. },
  181. handleChoose(e){
  182. let index = e.currentTarget.dataset.index;
  183. this.data.items[index].is_choose = !this.data.items[index].is_choose;
  184. this.data.items.forEach((v,idx)=>{
  185. if(idx!==index){
  186. v.is_choose = false;
  187. }
  188. })
  189. this.setData({
  190. items : this.data.items
  191. })
  192. },
  193. bindDateChange1(e){
  194. this.setData({
  195. start_date: e.detail.value
  196. })
  197. },
  198. bindDateChange(e) {
  199. this.setData({
  200. end_date: e.detail.value
  201. })
  202. },
  203. onChange(event) {
  204. this.setData({
  205. radio: event.detail,
  206. });
  207. },
  208. onClick(event) {
  209. const { name } = event.currentTarget.dataset;
  210. this.setData({
  211. radio: name,
  212. });
  213. },
  214. onConfirm1() {
  215. this.selectComponent('#item').toggle();
  216. this.data.page_index = 1;
  217. let app = getApp();
  218. let openid = app.globalData.openID;
  219. wx.showLoading({
  220. title: '加载中',
  221. });
  222. let data = {
  223. page_index: this.data.page_index,
  224. page_size: this.data.page_size,
  225. vin_no:this.data.vin_no,
  226. crt_time: [this.data.start_date?Date.parse(this.data.start_date).toString().slice(0,10):'',this.data.end_date?Date.parse(this.data.end_date).toString().slice(0,10):''],
  227. status:this.data.radio==3?'':this.data.radio
  228. }
  229. wx.p.request({
  230. url: `${app.globalData.url}wx/constructionList`,
  231. method:'POST',
  232. data:{
  233. openid,
  234. ...data
  235. }
  236. }).then(res=>{
  237. if(res.data.code==200){
  238. res.data.data.data.forEach(element => {
  239. element.is_choose = false;
  240. });
  241. this.setData({
  242. items:res.data.data.data
  243. })
  244. // 加载完毕后隐藏加载提示
  245. wx.hideLoading();
  246. }
  247. })
  248. },
  249. initData(){
  250. let app = getApp();
  251. let openid = app.globalData.openID;
  252. wx.showLoading({
  253. title: '加载中',
  254. });
  255. let data = {
  256. page_index: this.data.page_index,
  257. page_size: this.data.page_size,
  258. vin_no:this.data.vin_no,
  259. crt_time: [this.data.start_date?Date.parse(this.data.start_date).toString().slice(0,10):'',this.data.end_date?Date.parse(this.data.end_date).toString().slice(0,10):''],
  260. status:this.data.radio==3?'':this.data.radio
  261. }
  262. wx.p.request({
  263. url: `${app.globalData.url}wx/constructionList`,
  264. method:'POST',
  265. data:{
  266. openid,
  267. ...data
  268. }
  269. }).then(res=>{
  270. if(res.data.code==200){
  271. res.data.data.data.forEach(element => {
  272. element.is_choose = false;
  273. });
  274. let arr = [...this.data.items,...res.data.data.data];
  275. this.setData({
  276. items:arr
  277. })
  278. // 加载完毕后隐藏加载提示
  279. wx.hideLoading();
  280. }
  281. })
  282. },
  283. handleReturn(){
  284. wx.redirectTo({
  285. url: '../../../../pages/zero/zero',
  286. })
  287. },
  288. onReachBottom: function() {
  289. var that = this;
  290. // 加载更多数据
  291. let nextPage = that.data.page_index + 1;
  292. // 调用API请求数据,假设返回的数据是newItems
  293. // let newItems = api.getData(nextPage);
  294. // 将新数据添加到原有数据列表的末尾
  295. // let items = this.data.items.concat(newItems);
  296. // 更新页面数据
  297. that.setData({
  298. page_index: nextPage,
  299. });
  300. that.initData();
  301. },
  302. /**
  303. * 生命周期函数--监听页面加载
  304. */
  305. onLoad(options) {
  306. this.initData()
  307. },
  308. /**
  309. * 生命周期函数--监听页面初次渲染完成
  310. */
  311. onReady() {
  312. },
  313. /**
  314. * 生命周期函数--监听页面显示
  315. */
  316. onShow() {
  317. },
  318. /**
  319. * 生命周期函数--监听页面隐藏
  320. */
  321. onHide() {
  322. },
  323. /**
  324. * 生命周期函数--监听页面卸载
  325. */
  326. onUnload() {
  327. },
  328. /**
  329. * 页面相关事件处理函数--监听用户下拉动作
  330. */
  331. onPullDownRefresh() {
  332. },
  333. /**
  334. * 用户点击右上角分享
  335. */
  336. onShareAppMessage() {
  337. }
  338. })