电速宝
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

index.js 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. // pages/createorder/index.js
  2. const api = require('../../../api/index.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. cartype:1,
  9. index:0,
  10. objectArray: [],
  11. objdriver: [],
  12. driverindex:0,
  13. date: '',
  14. time: '', // 初始时间
  15. userdata:[],
  16. userindex:0,
  17. addressindex:'',
  18. address: [],
  19. items: [
  20. {value: 1, name: '光伏'},
  21. {value: 2, name: '风电'},
  22. {value: 3, name: '网电'},
  23. ],
  24. greenelectricity:0,
  25. workorderpower:'',
  26. orderdata:[],
  27. orderid:'',
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad(options) {
  33. console.log(options);
  34. this.getaddress()
  35. if (options.order!='') {
  36. this.setData({
  37. orderid:options.order
  38. })
  39. this.getoneworkorder()
  40. }
  41. // this.getdriver()
  42. // this.getvehicle()
  43. },
  44. // 订单详情
  45. getoneworkorder() {
  46. const data = {
  47. workorderId: this.data.orderid
  48. };
  49. api.request(`/sysworkorder/selectworkorderId`, 'post', data, { isPublic: false })
  50. .then((data) => {
  51. if (data.code == 200) {
  52. this.setData({
  53. cartype:data.data.chargedischargeType,
  54. workorderElectricity:data.data.workorderElectricity,
  55. workorderpower:data.data.workorderPower,
  56. greenelectricity:data.data.greenelectricity,
  57. date:data.data.workorderStarttime.slice(0,10),
  58. time:data.data.workorderStarttime.slice(11,16),
  59. })
  60. for (let index = 0; index < this.data.address.length; index++) {
  61. if (data.data.addressId==this.data.address[index].addressId) {
  62. this.setData({
  63. addressindex:index
  64. })
  65. }
  66. }
  67. }
  68. })
  69. .catch((err) => {
  70. console.error('获取工单信息失败:', err);
  71. this.showInfo('获取工单信息失败');
  72. });
  73. },
  74. // 司机
  75. getdriver(){
  76. let data ={
  77. }
  78. api.request(`/sysdriver/selectdriverall`, 'post',data,{ isPublic: false })
  79. .then((data) => {
  80. console.log(data.data);
  81. let obj = []
  82. for (let index = 0; index < data.data.length; index++) {
  83. let carType = ''
  84. if (data.data[index].operationType==1) {
  85. carType = '空闲'
  86. }else if(data.data[index].operationType==2){
  87. carType = '工作中'
  88. }else if(data.data[index].operationType==3){
  89. carType = '维护中'
  90. }
  91. obj.push({
  92. id:data.data[index].operationId,
  93. name:data.data[index].operationName,
  94. subtitle:data.data[index].operationName + ' / ' + carType
  95. })
  96. }
  97. this.setData({
  98. objdriver:obj
  99. })
  100. })
  101. .catch((err) => {
  102. console.error('请求失败:', err);
  103. });
  104. },
  105. // 车型
  106. getvehicle(){
  107. let data ={}
  108. api.request(`/syscar/selectcarall`, 'post',data,{ isPublic: false })
  109. .then((data) => {
  110. let obj = []
  111. for (let index = 0; index < data.data.length; index++) {
  112. let carType = ''
  113. if (data.data[index].carType==1) {
  114. carType = '空闲'
  115. }else if(data.data[index].carType==2){
  116. carType = '工作中'
  117. }else if(data.data[index].carType==3){
  118. carType = '维护中'
  119. }
  120. obj.push({
  121. id:data.data[index].carId,
  122. name:data.data[index].carId + ' / ' + data.data[index].carMondel,
  123. subtitle:data.data[index].carId + ' / ' + data.data[index].carMondel + ' / ' + carType
  124. })
  125. }
  126. this.setData({
  127. objectArray:obj
  128. })
  129. console.log(this.data.objectArray);
  130. })
  131. .catch((err) => {
  132. console.error('请求失败:', err);
  133. });
  134. },
  135. // 地址
  136. getaddress(){
  137. let data ={
  138. operationId:''
  139. }
  140. api.request(`/sysaddress/selectaddress`, 'post',data,{ isPublic: false })
  141. .then((data) => {
  142. console.log(data.data);
  143. this.setData({
  144. address:data.data
  145. })
  146. })
  147. .catch((err) => {
  148. console.error('请求失败:', err);
  149. });
  150. },
  151. oncar(e){
  152. console.log(e.currentTarget.dataset.index);
  153. this.setData({
  154. cartype:e.currentTarget.dataset.index
  155. })
  156. },
  157. bindDateChange(e) {
  158. console.log('picker发送选择改变,携带值为', e.detail.value)
  159. this.setData({
  160. date: e.detail.value
  161. })
  162. },
  163. // 时间选择变化
  164. bindTimeChange(e) {
  165. this.setData({ time: e.detail.value });
  166. },
  167. // 需求电量
  168. bindKeyInput (e) {
  169. this.setData({
  170. workorderElectricity: e.detail.value
  171. })
  172. },
  173. bindintentionInput (e) {
  174. this.setData({
  175. workorderpower: e.detail.value
  176. })
  177. },
  178. details(){
  179. if (this.data.workorderElectricity==''||this.data.date==''||this.data.time==''||this.data.workorderpower=='') {
  180. wx.showToast({
  181. title: '请填写完整消息',
  182. icon: 'none'
  183. });
  184. return
  185. }
  186. let data ={
  187. addressId:this.data.address[this.data.addressindex].addressId,
  188. workorderElectricity:this.data.workorderElectricity,
  189. chargedischargeType:this.data.cartype,
  190. greenelectricity:this.data.greenelectricity,
  191. workorderStarttime:this.data.date+' '+this.data.time,
  192. workorderpower:this.data.workorderpower
  193. }
  194. api.request(`/sysworkorder/addworkorder`, 'post',data,{ isPublic: false })
  195. .then((data) => {
  196. console.log(data);
  197. wx.switchTab({
  198. url: '/pages/tool/index',
  199. })
  200. })
  201. .catch((err) => {
  202. console.error('请求失败:', err);
  203. });
  204. },
  205. // 编辑
  206. editdetails(){
  207. if (this.data.workorderElectricity==''||this.data.date==''||this.data.time==''||this.data.workorderpower=='') {
  208. wx.showToast({
  209. title: '请填写完整消息',
  210. icon: 'none'
  211. });
  212. return
  213. }
  214. let data ={
  215. workorderId:this.data.orderid,
  216. addressId:this.data.address[this.data.addressindex].addressId,
  217. workorderElectricity:this.data.workorderElectricity,
  218. chargedischargeType:this.data.cartype,
  219. greenelectricity:this.data.greenelectricity,
  220. workorderStarttime:this.data.date+' '+this.data.time,
  221. workorderpower:this.data.workorderpower
  222. }
  223. api.request(`/sysworkorder/updateworkorder`, 'post',data,{ isPublic: false })
  224. .then((data) => {
  225. console.log(data);
  226. wx.switchTab({
  227. url: '/pages/tool/index',
  228. })
  229. })
  230. .catch((err) => {
  231. console.error('请求失败:', err);
  232. });
  233. },
  234. // 司机
  235. bindectArrayChange(e){
  236. console.log(e.detail.value);
  237. this.setData({
  238. index:e.detail.value
  239. })
  240. },
  241. // 车型
  242. binddriverChange(e){
  243. console.log(e.detail.value);
  244. this.setData({
  245. driverindex:e.detail.value
  246. })
  247. },
  248. // 用户
  249. binduserChange(e){
  250. console.log(e);
  251. this.setData({
  252. userindex:e.detail.value
  253. })
  254. },
  255. // 地址
  256. bindPickerChange(e){
  257. console.log(e);
  258. this.setData({
  259. addressindex:e.detail.value
  260. })
  261. },
  262. radioChange(e) {
  263. console.log('radio发生change事件,携带value值为:', e.detail.value)
  264. // const items = this.data.items
  265. // for (let i = 0, len = items.length; i < len; ++i) {
  266. // items[i].checked = items[i].value === e.detail.value
  267. // }
  268. this.setData({
  269. greenelectricity:e.detail.value
  270. })
  271. console.log(this.data.greenelectricity);
  272. },
  273. toconfigure(){
  274. wx.navigateTo({
  275. url: '/package-order/pages/address/index',
  276. });
  277. },
  278. /**
  279. * 生命周期函数--监听页面初次渲染完成
  280. */
  281. onReady() {
  282. },
  283. /**
  284. * 生命周期函数--监听页面显示
  285. */
  286. onShow() {
  287. this.getaddress()
  288. },
  289. /**
  290. * 生命周期函数--监听页面隐藏
  291. */
  292. onHide() {
  293. },
  294. /**
  295. * 生命周期函数--监听页面卸载
  296. */
  297. onUnload() {
  298. },
  299. /**
  300. * 页面相关事件处理函数--监听用户下拉动作
  301. */
  302. onPullDownRefresh() {
  303. },
  304. /**
  305. * 页面上拉触底事件的处理函数
  306. */
  307. onReachBottom() {
  308. },
  309. /**
  310. * 用户点击右上角分享
  311. */
  312. onShareAppMessage() {
  313. }
  314. })
  315. //