add.vue 17 KB

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