电速宝
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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