add.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  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" @delete="deletefileUrlList" :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. <span class="label">联系方式</span>
  69. <span class="tit" style="position: relative">
  70. <input type="text" placeholder="请输入联系方式" v-model="form.contact" />
  71. </span>
  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.remark" 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. deletefileUrlList(event){
  271. // fileUrlList
  272. this.fileUrlList.splice(event.detail.index, 1);
  273. },
  274. closePicker() {
  275. this.showPicker = false;
  276. },
  277. getName() {
  278. console.log(123, this.name);
  279. let that = this;
  280. getDispatchToPerson({ name: this.name, groupId: "" }).then((res) => {
  281. that.columns = res.data;
  282. that.$forceUpdate();
  283. });
  284. },
  285. afterRead(event) {
  286. let that = this;
  287. const { file } = event.detail;
  288. console.log(file);
  289. uni.uploadFile({
  290. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  291. filePath: file[0].url,
  292. name: "file",
  293. formData: { user: "test" },
  294. success(res) {
  295. let { data } = JSON.parse(res.data);
  296. console.log(data[0]);
  297. that.fileUrlList.push({
  298. id: data[0],
  299. url:
  300. that.$constant.BASE_URI + "/FileController/download/" + data[0],
  301. isImage: true,
  302. });
  303. that.fileUrlList = [...that.fileUrlList];
  304. that.$forceUpdate();
  305. console.log(that.fileUrlList);
  306. },
  307. fail(res) { },
  308. });
  309. },
  310. submit() {
  311. let that = this;
  312. if(!that.form.handleUserName||that.form.handleUserName.length==0){
  313. this.$showToast("请选择处理人");
  314. return;
  315. }
  316. if (that.quickSleced.value == null || that.quickSleced.value === "") {
  317. this.$showToast("请选择服务类型");
  318. return;
  319. }
  320. if (!that.form.contact || that.form.contact.length == 0) {
  321. this.$showToast("请输入联系方式");
  322. return;
  323. }
  324. let localStorageInfo = getUserLocalStorageInfo().user;
  325. that.form.groupId = "870261874875170816"; // 园区
  326. // that.form.fileUrl = JSON.stringify(that.fileUrlList);
  327. let fileUrlList = "";
  328. if (that.fileUrlList && that.fileUrlList.length > 0) {
  329. fileUrlList = that.fileUrlList.map((e) => {
  330. return e.id;
  331. });
  332. }
  333. that.form.fileUrl = fileUrlList ? fileUrlList.join(",") : [];
  334. that.form.userId = localStorageInfo.id
  335. that.form.serviceType = this.quickSleced.value;
  336. that.form.createdBy = localStorageInfo.id;
  337. addRepair(that.form).then((res) => {
  338. that.$showToast("填报成功");
  339. uni.navigateBack({});
  340. // this.$router.push({
  341. // path: "/repairDispatch-app",
  342. // });
  343. });
  344. },
  345. changePosition(val) { },
  346. },
  347. };
  348. </script>
  349. <style lang="scss" scoped>
  350. // .youwill {
  351. // width: 50%;
  352. // float: left;
  353. // }
  354. .list-row1 {
  355. width: calc(100% - 64rpx);
  356. padding: 16rpx 32rpx 18rpx 32rpx;
  357. background: #ffffff;
  358. display: flex;
  359. //height: 278rpx;
  360. border-radius: 8rpx 8rpx 8rpx 8rpx;
  361. }
  362. .custom-item-tit {
  363. height: 13.333vw;
  364. font-size: 4.267vw;
  365. color: #333;
  366. padding: 2.667vw 0;
  367. position: relative;
  368. display: flex;
  369. -webkit-box-pack: justify;
  370. -ms-flex-pack: justify;
  371. justify-content: space-between;
  372. -webkit-box-align: center;
  373. -ms-flex-align: center;
  374. align-items: center;
  375. box-sizing: border-box;
  376. .tit {
  377. padding-left: 2.667vw;
  378. position: relative;
  379. &::after {
  380. content: "";
  381. width: 0.8vw;
  382. height: 90%;
  383. background-color: #976dec;
  384. border-radius: 0.4vw;
  385. position: absolute;
  386. left: 0;
  387. top: 50%;
  388. -webkit-transform: translateY(-50%);
  389. transform: translateY(-50%);
  390. }
  391. }
  392. }
  393. .fixed-page-content {
  394. width: 100%;
  395. height: 100%;
  396. padding-bottom: 190px;
  397. box-sizing: border-box;
  398. overflow-y: auto;
  399. }
  400. .icon-daichulihetong:before {
  401. content: "\e639";
  402. }
  403. .repair-box-add {
  404. width: 100%;
  405. height: 100%;
  406. .page-1 {
  407. font-size: 30rpx;
  408. color: #6600ff;
  409. padding: 30rpx;
  410. box-sizing: border-box;
  411. .page-1-head {
  412. display: flex;
  413. align-items: center;
  414. justify-content: flex-end;
  415. i {
  416. font-size: 38rpx;
  417. margin-right: 10rpx;
  418. }
  419. }
  420. }
  421. .page-2 {
  422. .van-cell {
  423. padding: 20rpx;
  424. border-radius: 10rpx;
  425. background: $page-color-base;
  426. box-sizing: border-box;
  427. textarea {
  428. height: 60rpx;
  429. }
  430. }
  431. }
  432. }
  433. .custom-input-box {
  434. height: 80rpx;
  435. color: $text3;
  436. font-size: 30rpx;
  437. background: $home-bg-color;
  438. border-radius: 10rpx;
  439. .txt {
  440. width: 100%;
  441. height: 100%;
  442. text-align: center;
  443. padding: 0 20rpx;
  444. line-height: 80rpx;
  445. box-sizing: border-box;
  446. }
  447. input {
  448. width: 100%;
  449. height: 100%;
  450. background: transparent;
  451. border: transparent;
  452. padding: 0 20rpx;
  453. color: $text3;
  454. box-sizing: border-box;
  455. }
  456. }
  457. .cell-item {
  458. color: #333;
  459. padding: 30rpx 0;
  460. display: flex;
  461. justify-content: space-between;
  462. position: relative;
  463. &::after {
  464. position: absolute;
  465. box-sizing: border-box;
  466. content: " ";
  467. pointer-events: none;
  468. right: 0;
  469. bottom: 0;
  470. left: 0;
  471. border-bottom: 1rpx solid #ebedf0;
  472. -webkit-transform: scaleY(0.5);
  473. transform: scaleY(0.5);
  474. }
  475. .label {
  476. flex: 1;
  477. width: 30%;
  478. .tips {
  479. font-size: 22rpx;
  480. color: #dddddd;
  481. }
  482. &.required {
  483. position: relative;
  484. &::after {
  485. content: "*";
  486. color: #fd4e4e;
  487. position: absolute;
  488. font-size: 30rpx;
  489. top: -15rpx;
  490. left: -15rpx;
  491. }
  492. }
  493. }
  494. .tit {
  495. color: #333;
  496. flex: 1;
  497. width: 70%;
  498. text-align: right;
  499. }
  500. }
  501. .white-box {
  502. width: 100%;
  503. font-size: 28rpx;
  504. padding: 0 40rpx;
  505. background-color: #ffffff;
  506. box-sizing: border-box;
  507. &:not(:last-child) {
  508. margin-bottom: 30rpx;
  509. }
  510. .flex-item {
  511. align-items: center;
  512. .tel-box {
  513. display: flex;
  514. align-items: center;
  515. justify-content: flex-end;
  516. .custom-tel-component {
  517. margin-left: 20rpx;
  518. }
  519. }
  520. }
  521. .cell-item {
  522. color: #333;
  523. padding: 30rpx 0;
  524. display: flex;
  525. justify-content: space-between;
  526. position: relative;
  527. &::after {
  528. position: absolute;
  529. box-sizing: border-box;
  530. content: " ";
  531. pointer-events: none;
  532. right: 0;
  533. bottom: 0;
  534. left: 0;
  535. border-bottom: 1rpx solid #ebedf0;
  536. -webkit-transform: scaleY(0.5);
  537. transform: scaleY(0.5);
  538. }
  539. .label {
  540. flex: 1;
  541. width: 30%;
  542. .tips {
  543. font-size: 22rpx;
  544. color: #dddddd;
  545. }
  546. &.required {
  547. position: relative;
  548. &::after {
  549. content: "*";
  550. color: var#fd4e4e;
  551. position: absolute;
  552. font-size: 30rpx;
  553. top: -15rpx;
  554. left: -15rpx;
  555. }
  556. }
  557. }
  558. .tit {
  559. color: #333;
  560. flex: 1;
  561. width: 70%;
  562. text-align: right;
  563. }
  564. }
  565. .block-cell-item {
  566. color: #333;
  567. padding: 30rpx 0;
  568. position: relative;
  569. &::after {
  570. position: absolute;
  571. box-sizing: border-box;
  572. content: " ";
  573. pointer-events: none;
  574. right: 16rpx;
  575. bottom: 0;
  576. left: 16rpx;
  577. border-bottom: 1rpx solid #ebedf0;
  578. -webkit-transform: scaleY(0.5);
  579. transform: scaleY(0.5);
  580. }
  581. .label {
  582. width: 100%;
  583. padding-bottom: 30rpx;
  584. &.required {
  585. position: relative;
  586. &::after {
  587. content: "*";
  588. color: #fd4e4e;
  589. position: absolute;
  590. font-size: 30rpx;
  591. top: -15rpx;
  592. left: -15rpx;
  593. }
  594. }
  595. .tips {
  596. font-size: 22rpx;
  597. color: #dddddd;
  598. }
  599. }
  600. .tit {
  601. width: 100%;
  602. color: #333;
  603. .textarea {
  604. background-color: #f8f8f8;
  605. font-size: 30rpx;
  606. color: #b7b7b7;
  607. border-radius: 10rpx;
  608. padding: 30rpx;
  609. word-break: break-all;
  610. }
  611. }
  612. }
  613. .custom-white-box-content {
  614. padding-bottom: 30rpx;
  615. }
  616. }
  617. .custom-select-list {
  618. color: $color4;
  619. width: 100%;
  620. display: flex;
  621. flex-wrap: wrap;
  622. justify-content: space-between;
  623. li {
  624. font-size: 22rpx;
  625. margin-bottom: 25rpx;
  626. padding: 20rpx 0;
  627. width: 22%;
  628. text-align: center;
  629. overflow: hidden;
  630. text-overflow: ellipsis;
  631. white-space: nowrap;
  632. border-radius: 10rpx;
  633. border: 2rpx solid $text4;
  634. &.active {
  635. color: $text6;
  636. border-color: $text6;
  637. }
  638. }
  639. }
  640. .bottom-button {
  641. position: fixed;
  642. bottom: 0;
  643. left: 0;
  644. width: 100%;
  645. height: 160rpx;
  646. padding: 35rpx 30rpx;
  647. background-color: #fff;
  648. display: flex;
  649. align-items: center;
  650. justify-content: center;
  651. box-sizing: border-box;
  652. .btn {
  653. height: 100%;
  654. line-height: 80rpx;
  655. width: 100%;
  656. color: #fff;
  657. background-color: #6600ff;
  658. font-size: 34rpx;
  659. border-radius: 10rpx;
  660. }
  661. }
  662. </style>
  663. <style lang="scss">
  664. .repair-box-add {
  665. .van-radio-group {
  666. display: flex;
  667. .van-radio {
  668. width: 100%;
  669. padding-left: 30rpx;
  670. }
  671. .van-radio__label {}
  672. }
  673. }
  674. </style>