index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='故障报修'></cus-header>
  4. <div class="boxs">
  5. <div class="box">
  6. <div class="box_item">
  7. <div class="left">项目订单号</div>
  8. <div class="right select" @tap="handleSelect(1)">
  9. <text>{{orderNoText}}</text>
  10. <image :src="imgBase+'operation/arrow_right.png'" mode="widthFix"></image>
  11. </div>
  12. </div>
  13. <div class="box_item">
  14. <div class="left">报修地点</div>
  15. <div class="right select" @tap="handleSelect(2)">
  16. <text>{{placeText}}</text>
  17. <image :src="imgBase+'operation/arrow_right.png'" mode="widthFix"></image>
  18. </div>
  19. </div>
  20. <div class="box_item">
  21. <div class="left">产品名称</div>
  22. <div class="right select" @tap="handleSelect(3)">
  23. <text>{{productText}}</text>
  24. <image :src="imgBase+'operation/arrow_right.png'" mode="widthFix"></image>
  25. </div>
  26. </div>
  27. <div class="box_item">
  28. <div class="left">产品编号</div>
  29. <div class="right select" @tap="handleSelect(4)">
  30. <text>{{productNoText}}</text>
  31. <image :src="imgBase+'operation/arrow_right.png'" mode="widthFix"></image>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="box">
  36. <div class="box_item">
  37. <div class="left">故障发生时间</div>
  38. <div class="right select" @tap="handleSelect(5)">
  39. <text>{{dateText}}</text>
  40. <image :src="imgBase+'operation/arrow_right.png'" mode="widthFix"></image>
  41. </div>
  42. </div>
  43. <div class="box_item">
  44. <div class="left">故障类型</div>
  45. <div class="right select" @tap="handleSelect(6)">
  46. <text>{{typeText}}</text>
  47. <image :src="imgBase+'operation/arrow_right.png'" mode="widthFix"></image>
  48. </div>
  49. </div>
  50. <div class="box_item">
  51. <div class="left">报修人员</div>
  52. <div class="right">
  53. <input type="text" placeholder="请输入报修人员" placeholder-class="inp_ph" v-model="dto.maintainer">
  54. </div>
  55. </div>
  56. <div class="box_item2">
  57. <div class="top">故障描述</div>
  58. <div class="bottom">
  59. <u--textarea v-model="dto.description" placeholder="故障描述" placeholder-class="inp_ph2" border="none" height="110"></u--textarea>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="box">
  64. <div class="box_item2">
  65. <div class="top">故障照片</div>
  66. <div class="bottom" style="padding-top: 24rpx;">
  67. <u-upload width="180" height="180"
  68. :fileList="fileList"
  69. @afterRead="afterRead"
  70. @delete="deletePic"
  71. multiple
  72. :maxCount="5"
  73. ></u-upload>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <div class="bottom_btn">
  79. <div class="btn" @tap="submit">提交</div>
  80. </div>
  81. <u-picker :itemHeight="88" :show="show1" :columns="columns1" keyName="orderNo" title="项目订单号"
  82. @cancel="show1=false" @confirm="e=>confirm(e,1,'orderNoText','orderId','orderNo')" :immediateChange="true"></u-picker>
  83. <u-picker :itemHeight="88" :show="show2" :columns="columns2" keyName="customerName" title="报修地点"
  84. @cancel="show2=false" @confirm="e=>confirm(e,2,'placeText','customer','customerName')" :immediateChange="true"></u-picker>
  85. <u-picker :itemHeight="88" :show="show3" :columns="columns3" keyName="itemName" title="产品名称"
  86. @cancel="show3=false" @confirm="e=>confirm(e,3,'productText','skuId','itemName')" :immediateChange="true"></u-picker>
  87. <u-picker :itemHeight="88" :show="show4" :columns="columns4" keyName="productNo" title="产品编号"
  88. @cancel="show4=false" @confirm="e=>confirm(e,4,'productNoText','serialnumber','productNo')" :immediateChange="true"></u-picker>
  89. <u-datetime-picker :itemHeight="88" :show="show5" v-model="dto.happenDate" mode="date" title="故障发生时间"
  90. @cancel="show5=false" @confirm="e=>confirm(e,5)" :immediateChange="true" :minDate="minDate" :maxDate="maxDate"></u-datetime-picker>
  91. <u-picker :itemHeight="88" :show="show6" :columns="columns6" keyName="typeName" title="故障类型"
  92. @cancel="show6=false" @confirm="e=>confirm(e,6,'typeText','optCategory','typeName')" :immediateChange="true"></u-picker>
  93. </view>
  94. </template>
  95. <script>
  96. const baseApi = require('@/http/baseApi.js')
  97. export default {
  98. data(){
  99. return {
  100. dto:{
  101. orderId:'',
  102. customer:'',
  103. skuId:'',
  104. itemName:'',
  105. serialnumber:'',
  106. happenDate:'',
  107. optCategory:'',
  108. maintainer:'',
  109. description:'',
  110. faultFile:''
  111. },
  112. fileList:[],
  113. orderNoText:'请选择项目订单号',
  114. placeText:'请选择报修地点',
  115. productText:'请选择产品名称',
  116. productNoText:'请选择产品编号',
  117. dateText:'请选择故障发生时间',
  118. typeText:'请选择故障类型',
  119. show1:false,
  120. show2:false,
  121. show3:false,
  122. show4:false,
  123. show5:false,
  124. show6:false,
  125. columns1:[],
  126. columns2:[],
  127. columns3:[],
  128. columns4:[],
  129. columns6:[],
  130. minDate:'',
  131. maxDate:'',
  132. productList:[],
  133. productNoList:[],
  134. rules:[
  135. {key:'orderId',tip:'请选择项目订单号'},
  136. {key:'customer',tip:'请选择报修地点'},
  137. {key:'skuId',tip:'请选择产品名称'},
  138. {key:'serialnumber',tip:'请选择产品编号'},
  139. {key:'happenDate',tip:'请选择故障发生时间'},
  140. {key:'optCategory',tip:'请选择故障类型'},
  141. {key:'maintainer',tip:'请输入报修人员'},
  142. {key:'description',tip:'请输入故障描述'}
  143. ]
  144. }
  145. },
  146. onLoad() {
  147. let d = new Date();
  148. this.minDate = new Date(d.getFullYear()-3,d.getMonth()+1,d.getDate()).getTime();
  149. this.maxDate = new Date().getTime();
  150. this.getOrderList();
  151. this.getCustomerList();
  152. this.getTypeList();
  153. },
  154. methods:{
  155. getOrderList(){
  156. this.$api.get('/wms/project/getOrderPage',{page:1,limit:-1}).then(res=>{
  157. if(res.data.code===0){
  158. this.columns1 = [res.data.data.list];
  159. }else this.$showToast(res.data.msg)
  160. })
  161. },
  162. getCustomerList(){
  163. this.$api.get('/wms/project/getCustomerList',{page:1,limit:-1}).then(res=>{
  164. if(res.data.code!==0) return this.$showToast(res.data.msg)
  165. let list = res.data.data.map(d=>{return {id:d,customerName:d}})
  166. this.columns2 = [list]
  167. })
  168. },
  169. getTypeList(){
  170. this.$api.get('/sys/dict/data/getListByType/wms_operation_category').then(res=>{
  171. if(res.data.code===0){
  172. let list = res.data.data.map(d=>{return {id:d.dictValue,typeName:d.dictLabel}})
  173. this.columns6 = [list];
  174. }else this.$showToast(res.data.msg)
  175. })
  176. },
  177. handleSelect(type){
  178. if(type==3&&!this.dto.orderId) return this.$showToast('请先选择项目订单号')
  179. if(type==4&&!this.dto.itemName) return this.$showToast('请先选择产品名称')
  180. this['show'+type] = true;
  181. },
  182. confirm(e,type,param,key,key2){
  183. if(type!=5){
  184. this[param] = e.value[0][key2];
  185. this.dto[key] = e.value[0].id;
  186. if(type==3) this.dto.itemName = e.value[0][key2]
  187. }else{
  188. this.dateText = new Date(e.value).Format('yyyy-MM-dd');
  189. this.dto.happenDate = JSON.parse(JSON.stringify(this.dateText));
  190. }
  191. if(type==1){
  192. this.$api.get('/wms/shipmentOrder/getShipmentByProjectId/'+this.dto.orderId).then(res=>{
  193. if(res.data.code!==0) return this.$showToast(res.data.msg)
  194. this.productList = res.data.data;
  195. let list = res.data.data.map(d=>{return {id:d.skuId,itemName:d.itemName}})
  196. this.columns3 = [list]
  197. })
  198. }
  199. if(type==3){
  200. this.productNoList = this.productList.find(p => p.skuId === this.dto.skuId)?.serialnumbers||[];
  201. let list = this.productNoList.map(d=>{return {id:d,productNo:d}});
  202. this.columns4 = [list];
  203. }
  204. this['show'+type] = false;
  205. },
  206. // 删除图片
  207. deletePic(event) {
  208. this.fileList.splice(event.index, 1);
  209. },
  210. // 新增图片
  211. async afterRead(event) {
  212. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  213. let lists = [].concat(event.file);
  214. let fileListLen = this.fileList.length;
  215. lists.map((item) => {
  216. this.fileList.push({
  217. ...item,
  218. status: "uploading",
  219. message: "上传中",
  220. });
  221. });
  222. for (let i = 0; i < lists.length; i++) {
  223. const result = await this.uploadFilePromise(lists[i].url);
  224. let item = this.fileList[fileListLen];
  225. this.fileList.splice(
  226. fileListLen,
  227. 1,
  228. Object.assign(item, {
  229. status: "success",
  230. message: "",
  231. url: result,
  232. })
  233. );
  234. fileListLen++;
  235. }
  236. },
  237. uploadFilePromise(url) {
  238. return new Promise((resolve, reject) => {
  239. let a = uni.uploadFile({
  240. url: baseApi.BaseApi + '/uploadFile',
  241. filePath: url,
  242. name: "file",
  243. formData: {
  244. user: "test",
  245. },
  246. success: (res) => {
  247. setTimeout(() => {
  248. resolve(res.data.data);
  249. }, 1000);
  250. },
  251. });
  252. });
  253. },
  254. submit(){
  255. let idx = this.rules.findIndex(r=>!this.dto[r.key]==true);
  256. if(idx>-1) return this.$showToast(this.rules[idx].tip)
  257. let dto = JSON.parse(JSON.stringify(this.dto))
  258. this.dto.happenDate = new Date(dto.happenDate).Format('yyyy-MM-dd');
  259. this.$api.post('/wms/order/operation',this.dto).then(res=>{
  260. if(res.data.code!==0) return this.$showToast(res.data.msg)
  261. this.$showToast('报修成功')
  262. setTimeout(()=>{
  263. uni.navigateBack()
  264. },1500)
  265. })
  266. }
  267. }
  268. }
  269. </script>
  270. <style>
  271. .inp_ph{
  272. font-family: PingFangSC, PingFang SC;
  273. font-weight: 400;
  274. font-size: 28rpx;
  275. color: #B9C0C8;
  276. line-height: 40rpx;
  277. text-align: right;
  278. }
  279. .inp_ph2{
  280. font-family: PingFangSC, PingFang SC;
  281. font-weight: 400;
  282. font-size: 28rpx;
  283. color: #B9C0C8;
  284. line-height: 40rpx;
  285. text-align: left;
  286. }
  287. </style>
  288. <style scoped lang="less">
  289. ::v-deep .u-radio:last-child{
  290. margin-left: 93rpx !important;
  291. }
  292. ::v-deep .u-upload__button .u-icon__icon{
  293. font-size: 48rpx !important;
  294. }
  295. .page{
  296. padding-bottom: 168rpx;
  297. background: #F4F8FB;
  298. .boxs{
  299. padding: 0 24rpx;
  300. .box{
  301. background: #FFFFFF;
  302. border-radius: 16rpx;
  303. margin-top: 20rpx;
  304. padding: 0 24rpx;
  305. }
  306. }
  307. .box_item{
  308. display: flex;
  309. align-items: center;
  310. justify-content: space-between;
  311. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECEEF5;
  312. padding: 24rpx 0;
  313. .left{
  314. font-family: PingFangSC, PingFang SC;
  315. font-weight: 400;
  316. font-size: 30rpx;
  317. color: #1D2129;
  318. line-height: 42rpx;
  319. }
  320. .right{
  321. input{
  322. font-family: PingFangSC, PingFang SC;
  323. font-weight: 400;
  324. font-size: 28rpx;
  325. color: #4E5969;
  326. line-height: 40rpx;
  327. text-align: right;
  328. }
  329. &.select{
  330. display: flex;
  331. align-items: center;
  332. text{
  333. font-family: PingFangSC, PingFang SC;
  334. font-weight: 400;
  335. font-size: 28rpx;
  336. color: #B9C0C8;
  337. line-height: 40rpx;
  338. }
  339. image{
  340. width: 24rpx;
  341. height: 24rpx;
  342. margin-left: 10rpx;
  343. }
  344. }
  345. }
  346. }
  347. .box_item2{
  348. .top{
  349. font-family: PingFangSC, PingFang SC;
  350. font-weight: 400;
  351. font-size: 30rpx;
  352. color: #1D2129;
  353. line-height: 42rpx;
  354. padding-top: 24rpx;
  355. }
  356. .bottom{
  357. padding-bottom: 24rpx;
  358. input{
  359. font-family: PingFangSC, PingFang SC;
  360. font-weight: 400;
  361. font-size: 28rpx;
  362. color: #4E5969;
  363. line-height: 40rpx;
  364. }
  365. }
  366. }
  367. .bottom_btn{
  368. width: 100%;
  369. height: 148rpx;
  370. padding: 20rpx 48rpx;
  371. box-sizing: border-box;
  372. background: #FFFFFF;
  373. position: fixed;
  374. bottom: 0;
  375. left: 0;
  376. z-index: 9;
  377. .btn{
  378. width: 100%;
  379. height: 88rpx;
  380. background: #2E69EB;
  381. border-radius: 16rpx;
  382. font-family: PingFang-SC, PingFang-SC;
  383. font-weight: bold;
  384. font-size: 32rpx;
  385. color: #FFFFFF;
  386. line-height: 88rpx;
  387. text-align: center;
  388. }
  389. }
  390. }
  391. </style>