add.vue 14 KB

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