add.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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>{{orderNo}}</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.ccc">
  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.ddd">
  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.fff" :size="30" :iconSize="30">
  45. <u-radio :labelSize="30" label="正常"></u-radio>
  46. <u-radio :labelSize="30" label="有异常"></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.ggg" 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="label" title="项目订单号"
  76. @cancel="show1=false" @confirm="e=>confirm(e,1)" :immediateChange="true"></u-picker>
  77. <u-picker :itemHeight="88" :show="show2" :columns="columns3" keyName="label" 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.eee" 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. export default {
  85. data(){
  86. return {
  87. dto:{
  88. aaa:'',
  89. bbb:'',
  90. ccc:'',
  91. ddd:'',
  92. eee:'',
  93. fff:'',
  94. ggg:'',
  95. hhh:''
  96. },
  97. fileList:[],
  98. orderNo:'请选择项目订单号',
  99. placeText:'请选择巡检地点',
  100. dateText:'请选择巡检时间',
  101. show1:false,
  102. show2:false,
  103. show3:false,
  104. columns1:[[
  105. {value:1,label:'PO20250408001'},
  106. {value:2,label:'PO20250408002'}
  107. ]],
  108. columns3:[[
  109. {value:1,label:'长鑫科技集团股份有限公司'},
  110. {value:2,label:'峻凌电子(合肥)有限公司'}
  111. ]],
  112. minDate:'',
  113. maxDate:'',
  114. }
  115. },
  116. onLoad() {
  117. let d = new Date();
  118. this.minDate = new Date(d.getFullYear()-3,d.getMonth()+1,d.getDate()).getTime();
  119. this.maxDate = new Date().getTime();
  120. },
  121. methods:{
  122. handleSelect(type){
  123. if(type==1) this.show1 = true;
  124. else if(type==2) this.show2 = true;
  125. else if(type==3) this.show3 = true;
  126. },
  127. confirm(e,type){
  128. if(type==1){
  129. this.orderNo = e.value[0].label;
  130. this.dto.aaa = e.value[0].value;
  131. this.show1 = false;
  132. }else if(type==2){
  133. this.placeText = e.value[0].label;
  134. this.dto.bbb = e.value[0].value;
  135. this.show2 = false;
  136. }else if(type==3){
  137. this.dateText = new Date(e.value).Format('yyyy-MM-dd');
  138. this.dto.eee = JSON.parse(JSON.stringify(this.dateText));
  139. this.show3 = false;
  140. }
  141. },
  142. // 删除图片
  143. deletePic(event) {
  144. this.fileList.splice(event.index, 1);
  145. },
  146. // 新增图片
  147. async afterRead(event) {
  148. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  149. let lists = [].concat(event.file);
  150. let fileListLen = this.fileList.length;
  151. lists.map((item) => {
  152. this.fileList.push({
  153. ...item,
  154. status: "uploading",
  155. message: "上传中",
  156. });
  157. });
  158. for (let i = 0; i < lists.length; i++) {
  159. const result = await this.uploadFilePromise(lists[i].url);
  160. let item = this.fileList[fileListLen];
  161. this.fileList.splice(
  162. fileListLen,
  163. 1,
  164. Object.assign(item, {
  165. status: "success",
  166. message: "",
  167. url: result,
  168. })
  169. );
  170. fileListLen++;
  171. }
  172. },
  173. uploadFilePromise(url) {
  174. return new Promise((resolve, reject) => {
  175. let a = uni.uploadFile({
  176. url: "http://192.168.2.21:7001/upload", // 仅为示例,非真实的接口地址
  177. filePath: url,
  178. name: "file",
  179. formData: {
  180. user: "test",
  181. },
  182. success: (res) => {
  183. setTimeout(() => {
  184. resolve(res.data.data);
  185. }, 1000);
  186. },
  187. });
  188. });
  189. },
  190. submit(){
  191. uni.navigateBack()
  192. }
  193. }
  194. }
  195. </script>
  196. <style>
  197. .inp_ph{
  198. font-family: PingFangSC, PingFang SC;
  199. font-weight: 400;
  200. font-size: 28rpx;
  201. color: #B9C0C8;
  202. line-height: 40rpx;
  203. text-align: right;
  204. }
  205. .inp_ph2{
  206. font-family: PingFangSC, PingFang SC;
  207. font-weight: 400;
  208. font-size: 28rpx;
  209. color: #B9C0C8;
  210. line-height: 40rpx;
  211. text-align: left;
  212. }
  213. </style>
  214. <style scoped lang="less">
  215. ::v-deep .u-radio:last-child{
  216. margin-left: 93rpx !important;
  217. }
  218. ::v-deep .u-upload__button .u-icon__icon{
  219. font-size: 48rpx !important;
  220. }
  221. .page{
  222. padding-bottom: 168rpx;
  223. background: #F4F8FB;
  224. .boxs{
  225. padding: 0 24rpx;
  226. .box{
  227. background: #FFFFFF;
  228. border-radius: 16rpx;
  229. margin-top: 20rpx;
  230. padding: 0 24rpx;
  231. }
  232. }
  233. .box_item{
  234. display: flex;
  235. align-items: center;
  236. justify-content: space-between;
  237. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECEEF5;
  238. padding: 24rpx 0;
  239. .left{
  240. font-family: PingFangSC, PingFang SC;
  241. font-weight: 400;
  242. font-size: 30rpx;
  243. color: #1D2129;
  244. line-height: 42rpx;
  245. }
  246. .right{
  247. input{
  248. font-family: PingFangSC, PingFang SC;
  249. font-weight: 400;
  250. font-size: 28rpx;
  251. color: #4E5969;
  252. line-height: 40rpx;
  253. text-align: right;
  254. }
  255. &.select{
  256. display: flex;
  257. align-items: center;
  258. text{
  259. font-family: PingFangSC, PingFang SC;
  260. font-weight: 400;
  261. font-size: 28rpx;
  262. color: #B9C0C8;
  263. line-height: 40rpx;
  264. }
  265. image{
  266. width: 24rpx;
  267. height: 24rpx;
  268. margin-left: 10rpx;
  269. }
  270. }
  271. }
  272. }
  273. .box_item2{
  274. .top{
  275. font-family: PingFangSC, PingFang SC;
  276. font-weight: 400;
  277. font-size: 30rpx;
  278. color: #1D2129;
  279. line-height: 42rpx;
  280. padding-top: 24rpx;
  281. }
  282. .bottom{
  283. padding-bottom: 24rpx;
  284. input{
  285. font-family: PingFangSC, PingFang SC;
  286. font-weight: 400;
  287. font-size: 28rpx;
  288. color: #4E5969;
  289. line-height: 40rpx;
  290. }
  291. }
  292. }
  293. .bottom_btn{
  294. width: 100%;
  295. height: 148rpx;
  296. padding: 20rpx 48rpx;
  297. box-sizing: border-box;
  298. background: #FFFFFF;
  299. position: fixed;
  300. bottom: 0;
  301. left: 0;
  302. z-index: 9;
  303. .btn{
  304. width: 100%;
  305. height: 88rpx;
  306. background: #2E69EB;
  307. border-radius: 16rpx;
  308. font-family: PingFang-SC, PingFang-SC;
  309. font-weight: bold;
  310. font-size: 32rpx;
  311. color: #FFFFFF;
  312. line-height: 88rpx;
  313. text-align: center;
  314. }
  315. }
  316. }
  317. </style>