ticketHandle.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp();
  4. const util = require('../../../utils/jmsUtil.js');
  5. const api = require('../../../api/jms.js');
  6. import moment from 'moment'
  7. Page({
  8. data: {
  9. id:'',
  10. fines:'',
  11. memo:'',
  12. resultList:[],
  13. scrollShow:false,
  14. result:[],
  15. serviceId:'',
  16. keywords:'',
  17. wholeList:[],
  18. orderInfo:{
  19. consignee:'',
  20. mobile:'',
  21. address:'',
  22. bookDate:'',
  23. time:'',
  24. workerName:'',
  25. workerId:'' ,
  26. workerTel:''
  27. },
  28. selectValue:'',
  29. selectVisible:false,
  30. selectKey:'',
  31. timeList:[],
  32. currentDate:new Date().getTime(),
  33. max:5,
  34. uploadShow:true,
  35. isFinish:false,
  36. feedbackInfo:{
  37. noticeType:'',
  38. sendTime:'',
  39. },
  40. fileList: [],
  41. pictures:[],
  42. },
  43. // 事件处理函数
  44. onLoad(options) {
  45. if(options.id){
  46. this.setData({
  47. id:options.id
  48. });
  49. }
  50. this.getResultList();
  51. },
  52. onshow(){
  53. },
  54. finesInput(e){
  55. this.setData({
  56. fines:e.detail.value
  57. });
  58. },
  59. bindMemo(e){
  60. this.setData({
  61. memo:e.detail.value
  62. });
  63. },
  64. getResultList(){
  65. util.request(api.TicketResult, {
  66. }, 'GET').then(res=>{
  67. if (res.errno == 0) {
  68. this.setData({
  69. resultList:res.data
  70. });
  71. }else{
  72. wx.showToast({
  73. title: res.errmsg,
  74. icon:'none'
  75. })
  76. }
  77. });
  78. },
  79. inputClue(e){
  80. let obj=e.currentTarget.dataset.obj;
  81. let item=`clueInfo.${obj}`;
  82. this.setData({
  83. [item]:e.detail.value
  84. });
  85. // console.log(this.data.clueInfo);
  86. },
  87. selectClue(e){
  88. let obj=e.currentTarget.dataset.obj;
  89. this.setData({
  90. selectKey:obj,
  91. selectVisible:true
  92. });
  93. console.log(this.data.selectKey);
  94. },
  95. onPickerConfirm(e){
  96. console.log(e);
  97. let obj={
  98. label:e.detail.value.text,
  99. value:e.detail.value.value
  100. }
  101. this.setData({
  102. 'orderInfo.changeReason':obj,
  103. selectVisible:false
  104. });
  105. },
  106. onPickerCancel(){
  107. this.setData({
  108. selectVisible:true
  109. });
  110. },
  111. selectDate(){
  112. this.setData({
  113. scrollShow:true
  114. });
  115. },
  116. hidePicker(){
  117. this.setData({
  118. dateTimeVisible:false
  119. });
  120. },
  121. onDateTimeConfirm(e){
  122. console.log(e);
  123. this.setData({
  124. currentDate:e.detail,
  125. 'orderInfo.bookDate':util.formetdate(new Date(e.detail)),
  126. dateTimeVisible:false
  127. });
  128. },
  129. onPickerConfirm(e){
  130. console.log(e);
  131. this.setData({
  132. 'orderInfo.time':e.detail.value,
  133. selectVisible:false
  134. });
  135. },
  136. onPickerCancel(){
  137. this.setData({
  138. selectVisible:false
  139. });
  140. },
  141. inputAddress(e){
  142. this.setData({
  143. address:e.detail.value
  144. });
  145. },
  146. deleteImage (event) {
  147. const { fileList = [] } = this.data;
  148. fileList.splice(event.detail.index, 1)
  149. this.setData({
  150. fileList: fileList
  151. })
  152. let urls=[];
  153. fileList.forEach(function(e){
  154. urls.push(e.url);
  155. })
  156. this.setData({
  157. "pictures": urls
  158. })
  159. },
  160. afterRead(event) {
  161. console.log(event);
  162. const { file } = event.detail
  163. let that = this;
  164. const uploadTask = wx.uploadFile({
  165. url: api.StorageUpload,
  166. filePath: file.url,
  167. name: 'file',
  168. header: {
  169. 'X-JZ-Admin-Token': wx.getStorageSync('token')},
  170. success: function (res) {
  171. console.log(res);
  172. var _res = JSON.parse(res.data);
  173. if (_res.errno === 0) {
  174. var url = _res.data.fileUrl;
  175. that.data.pictures.push(url)
  176. const { fileList = [] } = that.data;
  177. fileList.push({ ...file, url: url });
  178. that.setData({
  179. fileList: fileList
  180. })
  181. }
  182. },
  183. fail: function (e) {
  184. wx.showModal({
  185. title: '错误',
  186. content: '上传失败',
  187. showCancel: false
  188. })
  189. },
  190. })
  191. },
  192. workerTap(e){
  193. let id=e.currentTarget.dataset.id;
  194. let name=e.currentTarget.dataset.name;
  195. let current=[];
  196. if(this.data.result.indexOf(id)>=0){
  197. current=this.data.result;
  198. current.splice(this.data.result.indexOf(id),1);
  199. }else{
  200. current=this.data.result;
  201. current.push(id);
  202. }
  203. this.setData({
  204. result:current
  205. });
  206. let resultName=[];
  207. current.forEach(item=>{
  208. let matchRes=this.data.resultList.filter(obj=>{return obj.id==item});
  209. resultName.push(matchRes[0].name)
  210. });
  211. this.setData({
  212. resultName:resultName
  213. });
  214. },
  215. resultCancel(){
  216. this.setData({
  217. result:[],
  218. resultName:[],
  219. scrollShow:false,
  220. })
  221. },
  222. resultConf(){
  223. this.setData({
  224. scrollShow:false,
  225. })
  226. },
  227. confTap(){
  228. if(this.data.result.length==0){
  229. wx.showToast({
  230. title: '请选择处理结果',
  231. icon:'none'
  232. });
  233. return false;
  234. }
  235. if(this.data.memo==''){
  236. wx.showToast({
  237. title: '请输入处理备注',
  238. icon:'none'
  239. });
  240. return false;
  241. }
  242. wx.showLoading({
  243. title: '加载中',
  244. })
  245. let params={
  246. id:this.data.id,
  247. result:this.data.result,
  248. memo:this.data.memo,
  249. fines:Number(this.data.fines),
  250. fileUrl:this.data.pictures
  251. }
  252. util.request(api.HandleTicket,
  253. params
  254. , 'POST').then(res=>{
  255. wx.hideLoading();
  256. if (res.errno == 0) {
  257. wx.showModal({
  258. title: '提示',
  259. content: '操作成功',
  260. showCancel:false,
  261. complete: (res) => {
  262. if (res.cancel) {
  263. }
  264. if (res.confirm) {
  265. wx.navigateBack({
  266. delta:1
  267. });
  268. }
  269. }
  270. })
  271. }else{
  272. wx.showToast({
  273. title: res.errmsg,
  274. icon:'none'
  275. })
  276. }
  277. }).catch(err=>{
  278. wx.hideLoading();
  279. });
  280. },
  281. })