add.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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">
  23. <input type="text" placeholder="请输入巡检任务" placeholder-class="inp_ph" v-model="dto.inspectionTask">
  24. </div>
  25. </div>
  26. <div class="box_item">
  27. <div class="left">巡检负责人</div>
  28. <div class="right">
  29. <input type="text" placeholder="请输入巡检负责人" placeholder-class="inp_ph" v-model="dto.inspector">
  30. </div>
  31. </div>
  32. <div class="box_item">
  33. <div class="left">巡检时间</div>
  34. <div class="right select" @tap="handleSelect(3)">
  35. <text>{{dateText}}</text>
  36. <image :src="imgBase+'operation/arrow_right.png'" mode="widthFix"></image>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="box">
  41. <div class="box_item">
  42. <div class="left">巡检结果</div>
  43. <div class="right">
  44. <u-radio-group v-model="dto.status" :size="30" :iconSize="30">
  45. <u-radio :labelSize="30" :label="0" :name="0">正常</u-radio>
  46. <u-radio :labelSize="30" :label="1" :name="1">有异常</u-radio>
  47. </u-radio-group>
  48. </div>
  49. </div>
  50. <div class="box_item2">
  51. <div class="top">备注</div>
  52. <div class="bottom">
  53. <u--textarea v-model="dto.remark" placeholder="请输入备注" placeholder-class="inp_ph2" border="none" height="110"></u--textarea>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="box">
  58. <div class="box_item2">
  59. <div class="top">巡检打卡</div>
  60. <div class="bottom" style="padding-top: 24rpx;">
  61. <u-upload width="180" height="180"
  62. :fileList="fileList"
  63. @afterRead="afterRead"
  64. @delete="deletePic"
  65. multiple
  66. :maxCount="5"
  67. ></u-upload>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="bottom_btn">
  73. <div class="btn" @tap="submit">提交</div>
  74. </div>
  75. <u-picker :itemHeight="88" :show="show1" :columns="columns1" keyName="orderNo" title="项目订单号"
  76. @cancel="show1=false" @confirm="e=>confirm(e,1)" :immediateChange="true"></u-picker>
  77. <u-picker :itemHeight="88" :show="show2" :columns="columns2" keyName="customerName" title="巡检地点"
  78. @cancel="show2=false" @confirm="e=>confirm(e,2)" :immediateChange="true"></u-picker>
  79. <u-datetime-picker :itemHeight="88" :show="show3" v-model="dto.startDate" mode="date" title="巡检时间"
  80. @cancel="show3=false" @confirm="e=>confirm(e,3)" :immediateChange="true" :minDate="minDate" :maxDate="maxDate"></u-datetime-picker>
  81. </view>
  82. </template>
  83. <script>
  84. const baseApi = require('@/http/baseApi.js')
  85. export default {
  86. data(){
  87. return {
  88. dto:{
  89. orderId:'',
  90. inspectionSite:'',
  91. inspectionTask:'',
  92. inspector:'',
  93. startDate:'',
  94. status:0,
  95. remark:'',
  96. inspectionFile:''
  97. },
  98. fileList:[],
  99. orderNoText:'请选择项目订单号',
  100. placeText:'请选择巡检地点',
  101. dateText:'请选择巡检时间',
  102. show1:false,
  103. show2:false,
  104. show3:false,
  105. columns1:[],
  106. columns2:[],
  107. minDate:'',
  108. maxDate:'',
  109. rules:[
  110. {key:'orderId',tip:'请选择项目订单号'},
  111. {key:'inspectionSite',tip:'请选择巡检地点'},
  112. {key:'inspectionTask',tip:'请输入巡检任务'},
  113. {key:'inspector',tip:'请输入巡检负责人'},
  114. {key:'startDate',tip:'请选择巡检时间'},
  115. // {key:'status',tip:'请选择巡检结果'},
  116. {key:'remark',tip:'请输入备注'},
  117. // {key:'inspectionFile',tip:'请选择巡检打卡图片'}
  118. ]
  119. }
  120. },
  121. onLoad() {
  122. let d = new Date();
  123. this.minDate = new Date(d.getFullYear()-1,d.getMonth()+1,d.getDate()).getTime();
  124. this.maxDate = new Date().getTime();
  125. this.getOrderList();
  126. this.getCustomerList();
  127. },
  128. methods:{
  129. getOrderList(){
  130. this.$api.get('/wms/project/getOrderPage',{page:1,limit:-1}).then(res=>{
  131. if(res.data.code===0){
  132. this.columns1 = [res.data.data.list];
  133. }else this.$showToast(res.data.msg)
  134. })
  135. },
  136. getCustomerList(){
  137. this.$api.get('/wms/project/getCustomerList',{page:1,limit:-1}).then(res=>{
  138. if(res.data.code!==0) return this.$showToast(res.data.msg)
  139. let list = res.data.data.map(d=>{return {id:d,customerName:d}})
  140. this.columns2 = [list]
  141. })
  142. },
  143. handleSelect(type){
  144. this['show'+type] = true;
  145. },
  146. confirm(e,type){
  147. if(type==1){
  148. this.orderNoText = e.value[0].orderNo;
  149. this.dto.orderId = e.value[0].id;
  150. this.show1 = false;
  151. }else if(type==2){
  152. this.placeText = e.value[0].customerName;
  153. this.dto.inspectionSite = e.value[0].id;
  154. this.show2 = false;
  155. }else if(type==3){
  156. this.dateText = new Date(e.value).Format('yyyy-MM-dd');
  157. this.dto.startDate = new Date(e.value).Format('yyyy-MM-dd hh:mm:ss');
  158. this.show3 = false;
  159. }
  160. },
  161. // 删除图片
  162. deletePic(event) {
  163. this.fileList.splice(event.index, 1);
  164. },
  165. // 新增图片
  166. async afterRead(event) {
  167. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  168. let lists = [].concat(event.file);
  169. let fileListLen = this.fileList.length;
  170. lists.map((item) => {
  171. this.fileList.push({
  172. ...item,
  173. status: "uploading",
  174. message: "上传中",
  175. });
  176. });
  177. for (let i = 0; i < lists.length; i++) {
  178. const result = await this.uploadFilePromise(lists[i].url);
  179. let item = this.fileList[fileListLen];
  180. this.fileList.splice(
  181. fileListLen,
  182. 1,
  183. Object.assign(item, {
  184. status: "success",
  185. message: "",
  186. url: result,
  187. })
  188. );
  189. fileListLen++;
  190. }
  191. },
  192. uploadFilePromise(url) {
  193. return new Promise((resolve, reject) => {
  194. let a = uni.uploadFile({
  195. url: baseApi.BaseApi + '/uploadFile',
  196. filePath: url,
  197. name: "file",
  198. formData: {
  199. user: "test",
  200. },
  201. success: (res) => {
  202. setTimeout(() => {
  203. resolve(res.data.data);
  204. }, 1000);
  205. },
  206. });
  207. });
  208. },
  209. submit(){
  210. let idx = this.rules.findIndex(r=>!this.dto[r.key]==true);
  211. if(idx>-1) return this.$showToast(this.rules[idx].tip)
  212. let dto = JSON.parse(JSON.stringify(this.dto))
  213. this.dto.startDate = new Date(dto.startDate).Format('yyyy-MM-dd hh:mm:ss');
  214. this.$api.post('/wms/order/inspection',this.dto).then(res=>{
  215. if(res.data.code!==0) return this.$showToast(res.data.msg)
  216. this.$showToast('操作成功')
  217. setTimeout(()=>{
  218. uni.navigateBack()
  219. },1500)
  220. })
  221. }
  222. }
  223. }
  224. </script>
  225. <style>
  226. .inp_ph{
  227. font-family: PingFangSC, PingFang SC;
  228. font-weight: 400;
  229. font-size: 28rpx;
  230. color: #B9C0C8;
  231. line-height: 40rpx;
  232. text-align: right;
  233. }
  234. .inp_ph2{
  235. font-family: PingFangSC, PingFang SC;
  236. font-weight: 400;
  237. font-size: 28rpx;
  238. color: #B9C0C8;
  239. line-height: 40rpx;
  240. text-align: left;
  241. }
  242. </style>
  243. <style scoped lang="less">
  244. ::v-deep .u-radio:last-child{
  245. margin-left: 93rpx !important;
  246. }
  247. ::v-deep .u-upload__button .u-icon__icon{
  248. font-size: 48rpx !important;
  249. }
  250. .page{
  251. padding-bottom: 168rpx;
  252. background: #F4F8FB;
  253. .boxs{
  254. padding: 0 24rpx;
  255. .box{
  256. background: #FFFFFF;
  257. border-radius: 16rpx;
  258. margin-top: 20rpx;
  259. padding: 0 24rpx;
  260. }
  261. }
  262. .box_item{
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECEEF5;
  267. padding: 24rpx 0;
  268. .left{
  269. font-family: PingFangSC, PingFang SC;
  270. font-weight: 400;
  271. font-size: 30rpx;
  272. color: #1D2129;
  273. line-height: 42rpx;
  274. }
  275. .right{
  276. input{
  277. font-family: PingFangSC, PingFang SC;
  278. font-weight: 400;
  279. font-size: 28rpx;
  280. color: #4E5969;
  281. line-height: 40rpx;
  282. text-align: right;
  283. }
  284. &.select{
  285. display: flex;
  286. align-items: center;
  287. text{
  288. font-family: PingFangSC, PingFang SC;
  289. font-weight: 400;
  290. font-size: 28rpx;
  291. color: #B9C0C8;
  292. line-height: 40rpx;
  293. }
  294. image{
  295. width: 24rpx;
  296. height: 24rpx;
  297. margin-left: 10rpx;
  298. }
  299. }
  300. }
  301. }
  302. .box_item2{
  303. .top{
  304. font-family: PingFangSC, PingFang SC;
  305. font-weight: 400;
  306. font-size: 30rpx;
  307. color: #1D2129;
  308. line-height: 42rpx;
  309. padding-top: 24rpx;
  310. }
  311. .bottom{
  312. padding-bottom: 24rpx;
  313. input{
  314. font-family: PingFangSC, PingFang SC;
  315. font-weight: 400;
  316. font-size: 28rpx;
  317. color: #4E5969;
  318. line-height: 40rpx;
  319. }
  320. }
  321. }
  322. .bottom_btn{
  323. width: 100%;
  324. height: 148rpx;
  325. padding: 20rpx 48rpx;
  326. box-sizing: border-box;
  327. background: #FFFFFF;
  328. position: fixed;
  329. bottom: 0;
  330. left: 0;
  331. z-index: 9;
  332. .btn{
  333. width: 100%;
  334. height: 88rpx;
  335. background: #2E69EB;
  336. border-radius: 16rpx;
  337. font-family: PingFang-SC, PingFang-SC;
  338. font-weight: bold;
  339. font-size: 32rpx;
  340. color: #FFFFFF;
  341. line-height: 88rpx;
  342. text-align: center;
  343. }
  344. }
  345. }
  346. </style>