add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <div class="repair-box-add">
  3. <div class="repair-content fixed-page-content">
  4. <div class="white-box page-2">
  5. <div class="custom-item-tit">
  6. <p class="tit">当前企业</p>
  7. </div>
  8. <div class="custom-white-box-content">
  9. <div class="custom-input-box">
  10. <input
  11. type="text"
  12. :maxlength="50"
  13. placeholder="请输入"
  14. v-model="form.companyName"
  15. />
  16. </div>
  17. </div>
  18. <div class="cell-item">
  19. <p class="label required">您是想</p>
  20. <div class="tit">
  21. <van-radio-group v-model="form.type">
  22. <van-radio name="1" checked-color="#976CEB" custom-class="youwill"
  23. >报事</van-radio
  24. >
  25. <van-radio name="2" checked-color="#976CEB" custom-class="youwill"
  26. >咨询</van-radio
  27. >
  28. </van-radio-group>
  29. </div>
  30. </div>
  31. <div class="block-cell-item">
  32. <p class="label">快捷选择</p>
  33. <div class="tit">
  34. <ul class="custom-select-list">
  35. <li
  36. v-for="item in dic_SelectList.QUICK_SELECTION"
  37. v-if="item.value !== ''"
  38. :key="item.value"
  39. :class="{
  40. active: quickSleced.value && item.value === quickSleced.value,
  41. }"
  42. @click="quickSelect(item)"
  43. >
  44. {{ item.label }}
  45. </li>
  46. </ul>
  47. <uni-easyinput
  48. type="textarea"
  49. autoHeight
  50. v-model="form.description"
  51. maxlength="800"
  52. class="bgcF9F9F9 height218rpx"
  53. placeholder="请输入"
  54. />
  55. </div>
  56. </div>
  57. </div>
  58. <div class="white-box page-3" style="padding-bottom: 200rpx">
  59. <div class="cell-item">
  60. <p class="label required">位置</p>
  61. <div class="tit">
  62. <van-radio-group v-model="form.position">
  63. <van-radio
  64. :name="item.val"
  65. checked-color="#976CEB"
  66. v-for="item in positionList"
  67. :key="item.val"
  68. @change="changePosition(item.val)"
  69. >{{ item.label }}</van-radio
  70. >
  71. </van-radio-group>
  72. </div>
  73. </div>
  74. <div class="block-cell-item">
  75. <p class="label">
  76. 补充说明<span class="tips"
  77. >(支持图片/视频上传限20M内,最多6张)</span
  78. >
  79. </p>
  80. <div class="tit">
  81. <van-uploader
  82. :multiple="true"
  83. :file-list="fileUrlList"
  84. :max-count="6"
  85. @after-read="afterRead"
  86. @before-delete="beforeDelete"
  87. :show-upload="true"
  88. >
  89. </van-uploader>
  90. </div>
  91. </div>
  92. <div class="cell-item">
  93. <p class="label">报事人</p>
  94. <p class="tit">{{ form.userId }}</p>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="repair-bottom bottom-button">
  99. <button class="btn" @click="submit()">提交</button>
  100. </div>
  101. </div>
  102. </template>
  103. <script>
  104. // "van-radio": "/wxcomponents/weapp/dist/radio/index",
  105. // "van-radio-group": "/wxcomponents/weapp/dist/radio-group/index",
  106. import vanRadio from "../../../wxcomponents/weapp/dist/radio/index";
  107. import vanRadioGroup from "../../../wxcomponents/weapp/dist/radio-group/index";
  108. import {
  109. getCompanyById,
  110. addRepair,
  111. getByCodes,
  112. getUserLocalStorageInfo,
  113. } from "@/js_sdk/http";
  114. export default {
  115. components: {
  116. vanRadio,
  117. vanRadioGroup,
  118. },
  119. data() {
  120. return {
  121. dic_SelectList: {},
  122. dic_key: ["QUICK_SELECTION"],
  123. reportTypeSleced: "1",
  124. quickSleced: {},
  125. quickList: [],
  126. positionSleced: "1",
  127. positionList: [
  128. {
  129. val: "1",
  130. label: "室内",
  131. },
  132. {
  133. val: "2",
  134. label: "公区",
  135. },
  136. ],
  137. fileUrlList: [],
  138. fileUrls: [],
  139. form: {
  140. groupId: "",
  141. companyId: "",
  142. companyName: "",
  143. type: "1",
  144. serviceType: "",
  145. description: "",
  146. position: "1",
  147. fileUrl: "",
  148. status: "unAcceptance",
  149. },
  150. };
  151. },
  152. onLoad() {
  153. this.getByCodes(this.dic_SelectList);
  154. this.form.userId =
  155. getUserLocalStorageInfo().user.truename +
  156. "-" +
  157. getUserLocalStorageInfo().user.phone;
  158. },
  159. methods: {
  160. async getByCodes() {
  161. let data = await getByCodes(JSON.stringify(this.dic_key));
  162. this.dic_SelectList = this.$common.handleDicList(data);
  163. },
  164. /**
  165. *
  166. */
  167. quickSelect(item) {
  168. if (this.quickSleced.value && this.quickSleced.value === item.value) {
  169. this.quickSleced = {};
  170. console.log(123);
  171. } else {
  172. console.log(item);
  173. this.quickSleced = item;
  174. this.form.description = "";
  175. this.form.description = this.form.description + item.label;
  176. }
  177. },
  178. /**
  179. * 上传文件
  180. */
  181. // afterRead(file) {
  182. // if (file instanceof Array) {
  183. // file.map((v) => {
  184. // this.uploadImg(v);
  185. // });
  186. // } else {
  187. // this.uploadImg(file);
  188. // }
  189. // },
  190. beforeDelete(file, detail) {
  191. // this.handleImagUrlList = []
  192. const vm = this;
  193. // name.index代表图片的索引
  194. vm.fileUrlList.splice(detail.index, 1);
  195. return (file, name) => {
  196. const fileIndex = name.index;
  197. vm.fileUrlList[detail.index].splice(fileIndex, 1);
  198. };
  199. },
  200. /**
  201. * 上传图片
  202. */
  203. afterRead(event) {
  204. let that = this;
  205. const { file } = event.detail;
  206. console.log(file);
  207. uni.uploadFile({
  208. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  209. filePath: file[0].url,
  210. name: "file",
  211. formData: { user: "test" },
  212. success(res) {
  213. let { data } = JSON.parse(res.data);
  214. console.log(data[0]);
  215. that.fileUrlList.push({
  216. id: data[0],
  217. url:
  218. that.$constant.BASE_URI + "/FileController/download/" + data[0],
  219. isImage: true,
  220. });
  221. that.fileUrlList = [...that.fileUrlList];
  222. that.$forceUpdate();
  223. console.log(that.fileUrlList);
  224. },
  225. fail(res) {},
  226. });
  227. },
  228. submit() {
  229. let that = this;
  230. if (that.quickSleced.value == null || that.quickSleced.value === "") {
  231. this.$showToast("请选择服务类型");
  232. return;
  233. }
  234. let localStorageInfo = getUserLocalStorageInfo().user;
  235. that.form.groupId = "870261874875170816"; // 园区
  236. // that.form.fileUrl = JSON.stringify(that.fileUrlList);
  237. let fileUrlList = "";
  238. if (that.fileUrlList && that.fileUrlList.length > 0) {
  239. fileUrlList = that.fileUrlList.map((e) => {
  240. return e.id;
  241. });
  242. }
  243. that.form.fileUrl = fileUrlList ? fileUrlList.join(",") : [];
  244. that.form.userId =
  245. localStorageInfo.id +
  246. "-" +
  247. localStorageInfo.truename +
  248. "-" +
  249. localStorageInfo.phone;
  250. that.form.serviceType = this.quickSleced.value;
  251. that.form.createdBy = localStorageInfo.id;
  252. addRepair(that.form).then((res) => {
  253. that.$showToast("填报成功");
  254. uni.navigateBack({});
  255. // this.$router.push({
  256. // path: "/repairDispatch-app",
  257. // });
  258. });
  259. },
  260. changePosition(val) {},
  261. },
  262. };
  263. </script>
  264. <style lang="scss" scoped>
  265. // .youwill {
  266. // width: 50%;
  267. // float: left;
  268. // }
  269. .custom-item-tit {
  270. height: 13.333vw;
  271. font-size: 4.267vw;
  272. color: #333;
  273. padding: 2.667vw 0;
  274. position: relative;
  275. display: flex;
  276. -webkit-box-pack: justify;
  277. -ms-flex-pack: justify;
  278. justify-content: space-between;
  279. -webkit-box-align: center;
  280. -ms-flex-align: center;
  281. align-items: center;
  282. box-sizing: border-box;
  283. .tit {
  284. padding-left: 2.667vw;
  285. position: relative;
  286. &::after {
  287. content: "";
  288. width: 0.8vw;
  289. height: 90%;
  290. background-color: #976dec;
  291. border-radius: 0.4vw;
  292. position: absolute;
  293. left: 0;
  294. top: 50%;
  295. -webkit-transform: translateY(-50%);
  296. transform: translateY(-50%);
  297. }
  298. }
  299. }
  300. .fixed-page-content {
  301. width: 100%;
  302. height: 100%;
  303. padding-bottom: 190px;
  304. box-sizing: border-box;
  305. overflow-y: auto;
  306. }
  307. .icon-daichulihetong:before {
  308. content: "\e639";
  309. }
  310. .repair-box-add {
  311. width: 100%;
  312. height: 100%;
  313. .page-1 {
  314. font-size: 30rpx;
  315. color: #6600ff;
  316. padding: 30rpx;
  317. box-sizing: border-box;
  318. .page-1-head {
  319. display: flex;
  320. align-items: center;
  321. justify-content: flex-end;
  322. i {
  323. font-size: 38rpx;
  324. margin-right: 10rpx;
  325. }
  326. }
  327. }
  328. .page-2 {
  329. .van-cell {
  330. padding: 20rpx;
  331. border-radius: 10rpx;
  332. background: $page-color-base;
  333. box-sizing: border-box;
  334. textarea {
  335. height: 60rpx;
  336. }
  337. }
  338. }
  339. }
  340. .custom-input-box {
  341. height: 80rpx;
  342. color: $text3;
  343. font-size: 30rpx;
  344. background: $home-bg-color;
  345. border-radius: 10rpx;
  346. .txt {
  347. width: 100%;
  348. height: 100%;
  349. text-align: center;
  350. padding: 0 20rpx;
  351. line-height: 80rpx;
  352. box-sizing: border-box;
  353. }
  354. input {
  355. width: 100%;
  356. height: 100%;
  357. background: transparent;
  358. border: transparent;
  359. padding: 0 20rpx;
  360. color: $text3;
  361. box-sizing: border-box;
  362. }
  363. }
  364. .cell-item {
  365. color: #333;
  366. padding: 30rpx 0;
  367. display: flex;
  368. justify-content: space-between;
  369. position: relative;
  370. &::after {
  371. position: absolute;
  372. box-sizing: border-box;
  373. content: " ";
  374. pointer-events: none;
  375. right: 0;
  376. bottom: 0;
  377. left: 0;
  378. border-bottom: 1rpx solid #ebedf0;
  379. -webkit-transform: scaleY(0.5);
  380. transform: scaleY(0.5);
  381. }
  382. .label {
  383. flex: 1;
  384. width: 30%;
  385. .tips {
  386. font-size: 22rpx;
  387. color: #dddddd;
  388. }
  389. &.required {
  390. position: relative;
  391. &::after {
  392. content: "*";
  393. color: #fd4e4e;
  394. position: absolute;
  395. font-size: 30rpx;
  396. top: -15rpx;
  397. left: -15rpx;
  398. }
  399. }
  400. }
  401. .tit {
  402. color: #333;
  403. flex: 1;
  404. width: 70%;
  405. text-align: right;
  406. }
  407. }
  408. .white-box {
  409. width: 100%;
  410. font-size: 28rpx;
  411. padding: 0 40rpx;
  412. background-color: #ffffff;
  413. box-sizing: border-box;
  414. &:not(:last-child) {
  415. margin-bottom: 30rpx;
  416. }
  417. .flex-item {
  418. align-items: center;
  419. .tel-box {
  420. display: flex;
  421. align-items: center;
  422. justify-content: flex-end;
  423. .custom-tel-component {
  424. margin-left: 20rpx;
  425. }
  426. }
  427. }
  428. .cell-item {
  429. color: #333;
  430. padding: 30rpx 0;
  431. display: flex;
  432. justify-content: space-between;
  433. position: relative;
  434. &::after {
  435. position: absolute;
  436. box-sizing: border-box;
  437. content: " ";
  438. pointer-events: none;
  439. right: 0;
  440. bottom: 0;
  441. left: 0;
  442. border-bottom: 1rpx solid #ebedf0;
  443. -webkit-transform: scaleY(0.5);
  444. transform: scaleY(0.5);
  445. }
  446. .label {
  447. flex: 1;
  448. width: 30%;
  449. .tips {
  450. font-size: 22rpx;
  451. color: #dddddd;
  452. }
  453. &.required {
  454. position: relative;
  455. &::after {
  456. content: "*";
  457. color: var#fd4e4e;
  458. position: absolute;
  459. font-size: 30rpx;
  460. top: -15rpx;
  461. left: -15rpx;
  462. }
  463. }
  464. }
  465. .tit {
  466. color: #333;
  467. flex: 1;
  468. width: 70%;
  469. text-align: right;
  470. }
  471. }
  472. .block-cell-item {
  473. color: #333;
  474. padding: 30rpx 0;
  475. position: relative;
  476. &::after {
  477. position: absolute;
  478. box-sizing: border-box;
  479. content: " ";
  480. pointer-events: none;
  481. right: 16rpx;
  482. bottom: 0;
  483. left: 16rpx;
  484. border-bottom: 1rpx solid #ebedf0;
  485. -webkit-transform: scaleY(0.5);
  486. transform: scaleY(0.5);
  487. }
  488. .label {
  489. width: 100%;
  490. padding-bottom: 30rpx;
  491. &.required {
  492. position: relative;
  493. &::after {
  494. content: "*";
  495. color: #fd4e4e;
  496. position: absolute;
  497. font-size: 30rpx;
  498. top: -15rpx;
  499. left: -15rpx;
  500. }
  501. }
  502. .tips {
  503. font-size: 22rpx;
  504. color: #dddddd;
  505. }
  506. }
  507. .tit {
  508. width: 100%;
  509. color: #333;
  510. .textarea {
  511. background-color: #f8f8f8;
  512. font-size: 30rpx;
  513. color: #b7b7b7;
  514. border-radius: 10rpx;
  515. padding: 30rpx;
  516. word-break: break-all;
  517. }
  518. }
  519. }
  520. .custom-white-box-content {
  521. padding-bottom: 30rpx;
  522. }
  523. }
  524. .custom-select-list {
  525. color: $color4;
  526. width: 100%;
  527. display: flex;
  528. flex-wrap: wrap;
  529. justify-content: space-between;
  530. li {
  531. font-size: 22rpx;
  532. margin-bottom: 25rpx;
  533. padding: 20rpx 0;
  534. width: 22%;
  535. text-align: center;
  536. overflow: hidden;
  537. text-overflow: ellipsis;
  538. white-space: nowrap;
  539. border-radius: 10rpx;
  540. border: 2rpx solid $text4;
  541. &.active {
  542. color: $text6;
  543. border-color: $text6;
  544. }
  545. }
  546. }
  547. .bottom-button {
  548. position: fixed;
  549. bottom: 0;
  550. left: 0;
  551. width: 100%;
  552. height: 160rpx;
  553. padding: 35rpx 30rpx;
  554. background-color: #fff;
  555. display: flex;
  556. align-items: center;
  557. justify-content: center;
  558. box-sizing: border-box;
  559. .btn {
  560. height: 100%;
  561. line-height: 80rpx;
  562. width: 100%;
  563. color: #fff;
  564. background-color: #6600ff;
  565. font-size: 34rpx;
  566. border-radius: 10rpx;
  567. }
  568. }
  569. </style>
  570. <style lang="scss">
  571. .repair-box-add {
  572. .van-radio-group {
  573. display: flex;
  574. .van-radio {
  575. width: 100%;
  576. padding-left: 30rpx;
  577. }
  578. .van-radio__label {
  579. }
  580. }
  581. }
  582. </style>