add.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <div class="addcompany">
  3. <div class="list">
  4. <div class="list-row" style="padding-top: 0">
  5. <div style="height: auto" class="width100">
  6. <div class="width100 mt24rpx padb24rpx border_bottom_ccc list_date">
  7. <div class="input_title float_left">
  8. <span style="color: red">*&nbsp;</span>安全检查类型
  9. </div>
  10. <div
  11. class="float_left width60 whitespacenowrap first_title height50rpx font28rpx"
  12. style="color: #777"
  13. >
  14. <picker
  15. :disabled="id != null"
  16. style="input_value float_left"
  17. @change="bindPickerChange"
  18. :value="form.testTypeIndex"
  19. :range="dic_SelectList.rectification_management_update_type"
  20. range-key="label"
  21. >
  22. {{
  23. !dic_SelectList.rectification_management_update_type[
  24. form.testTypeIndex
  25. ].label
  26. ? "未知类型"
  27. : dic_SelectList.rectification_management_update_type[
  28. form.testTypeIndex
  29. ].label
  30. }}
  31. </picker>
  32. </div>
  33. <textarea
  34. :disabled="id != null"
  35. v-model="form.info"
  36. :maxlength="2000"
  37. placeholder="请输入"
  38. type="textarea"
  39. style="
  40. height: 200rpx;
  41. background: rgba(249, 249, 249, 1);
  42. padding: 20rpx;
  43. width: calc(100% - 40rpx);
  44. "
  45. />
  46. <div
  47. style="
  48. background: rgba(249, 249, 249, 1);
  49. text-align: right;
  50. padding-right: 10px;
  51. padding-bottom: 10rpx;
  52. "
  53. >
  54. {{ form.info.length }}/2000
  55. </div>
  56. </div>
  57. <div
  58. class="width100 mt24rpx padb24rpx border_bottom_ccc list_date display_flex"
  59. style="display: flex"
  60. >
  61. <div class="input_title float_left">
  62. <span style="color: red">*&nbsp;</span>
  63. 整改位置
  64. </div>
  65. <div
  66. @click="getAuth()"
  67. class="float_left width60 first_title font28rpx"
  68. style="color: #777; height: auto"
  69. >
  70. <div
  71. style="color: #777; height: auto; width: 80%"
  72. class="float_left input_value"
  73. >
  74. {{ form.updateAddress }}
  75. </div>
  76. </div>
  77. </div>
  78. <div
  79. class="width100 mt24rpx padb24rpx border_bottom_ccc list_date height40rpx"
  80. >
  81. <div class="input_title float_left">
  82. <span style="color: red">*</span>
  83. 处理人
  84. </div>
  85. <view style="color: #777" class="input_value float_left">
  86. <!-- {{ !form.finishUserName ? "请选择" : form.finishUserName }} -->
  87. <uni-data-select
  88. v-model="form.finishUser"
  89. :localdata="clrList"
  90. ></uni-data-select>
  91. </view>
  92. </div>
  93. <div
  94. class="width100 mt24rpx padb24rpx border_bottom_ccc list_date height40rpx"
  95. >
  96. <div class="input_title float_left">要求完成日期</div>
  97. <div
  98. class="float_left width60 whitespacenowrap first_title height50rpx font28rpx"
  99. style="color: #777"
  100. >
  101. <picker
  102. :disabled="id != null"
  103. mode="date"
  104. @change="selectCarDate"
  105. >
  106. {{ form.needFinishTime ? form.needFinishTime : "请选择" }}
  107. </picker>
  108. </div>
  109. </div>
  110. <div class="width100 mt24rpx border_bottom_ccc list_date">
  111. <div class="input_title">整改处理前照片</div>
  112. <div style="margin-top: 24rpx">(支持图片上传10M内,最多6张)</div>
  113. <div
  114. class="custom-image-box"
  115. style="margin-top: 20rpx; margin-bottom: 36rpx"
  116. >
  117. <van-uploader
  118. :disabled="id != null"
  119. :max-count="6"
  120. @delete="deleteRYXXZP"
  121. :file-list="form.infoMorePictureUrlList"
  122. @after-read="uploadRYXXZP"
  123. :show-upload="true"
  124. />
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. <div class="save_button" @click="save()" v-if="id == null">保存</div>
  130. <div class="save_button" @click="getAuth()" v-if="id == null">
  131. 重新获取当前整改位置
  132. </div>
  133. </div>
  134. <select-dengjiyuan
  135. ref="selectDengjiyuan"
  136. :multiple="false"
  137. :range="range"
  138. :selectParent="false"
  139. :foldAll="true"
  140. rangeKey="name"
  141. idKey="id"
  142. @selectDengjiyuan="selectDengjiyuan"
  143. />
  144. <uni-file-picker v-show="false" ref="files" :auto-upload="false" />
  145. <multiple-select
  146. v-model="show"
  147. :data="companyAllList"
  148. :default-selected="defaultSelected"
  149. @confirm="confirm"
  150. ></multiple-select>
  151. </div>
  152. </template>
  153. <script>
  154. var QQMapWX = require("./txmap_sdk/qqmap-wx-jssdk");
  155. var qqmapsdk;
  156. const form = {
  157. infoMorePictureUrlList: [],
  158. testTypeIndex: 0,
  159. year: "2023",
  160. carDate: "2023-06-30",
  161. remark: "",
  162. checkInfo: "",
  163. info: "",
  164. updateAddressY: "",
  165. updateAddressX: "",
  166. updateAddress: "",
  167. };
  168. import multipleSelect from "../../subPackages/components/momo-multipleSelect/momo-multipleSelect";
  169. import selectDengjiyuan from "../../subPackages/components/select_dengjiyuan/tkitree.vue";
  170. import tools from "../../subPackages/components/tkitree/tools.js";
  171. import {
  172. getSelectUserTwo,
  173. getSelectDeptTwo,
  174. getByCodes,
  175. getUserLocalStorageInfo,
  176. addRectificationManagement,
  177. findSafetySelfCheckingManagetById,
  178. findUserListByRoleWuye,
  179. } from "@/js_sdk/http";
  180. export default {
  181. components: {
  182. multipleSelect,
  183. selectDengjiyuan,
  184. },
  185. data() {
  186. return {
  187. clrList: [],
  188. id: null,
  189. BASE_URI: this.$constant.BASE_URI,
  190. companyAllList: [],
  191. defaultSelected: [],
  192. show: false,
  193. bizhongIndex: 0,
  194. testList: [
  195. { label: "类型1", value: 1 },
  196. { label: "类型2", value: 2 },
  197. { label: "类型3", value: 3 },
  198. { label: "类型4", value: 4 },
  199. { label: "类型5", value: 5 },
  200. { label: "类型6", value: 6 },
  201. { label: "类型7", value: 7 },
  202. { label: "类型8", value: 8 },
  203. ],
  204. settleInTypeIndex: 0,
  205. range: [],
  206. zaitiList: [],
  207. imageStyles: {},
  208. listStyles: {},
  209. fileLists: [],
  210. activeNames: [],
  211. StatusBar: 0,
  212. dic_key: ["rectification_management_update_type"],
  213. dic_SelectList: {},
  214. search: {
  215. pageSize: 10,
  216. pageNum: 1,
  217. },
  218. form: { ...form },
  219. companyAllList: [],
  220. value: ["0"],
  221. modeIndex: -1,
  222. styleIndex: -1,
  223. current: 0,
  224. mode: "default",
  225. dotsStyles: {},
  226. swiperDotIndex: 0,
  227. };
  228. },
  229. onLoad(option) {
  230. this.getByCodes();
  231. this.id = option.id !== "null" ? option.id : null;
  232. this.form = null;
  233. this.isReport = option.isReport == 1 ? true : false;
  234. this.form = { ...form };
  235. this.form.infoMorePictureUrlList = [];
  236. this.form.createdBy = getUserLocalStorageInfo().user.id;
  237. // findUserListByRoleWuye()
  238. this.findUserListByRoleWuye();
  239. qqmapsdk = new QQMapWX({
  240. key: "OJ7BZ-ULH6V-XBLPV-ULIMK-APS3H-QHFIP",
  241. });
  242. this.getCurrentLocal();
  243. },
  244. onShow() {},
  245. methods: {
  246. async findUserListByRoleWuye() {
  247. let clrList = await findUserListByRoleWuye();
  248. this.clrList = clrList.map((e) => {
  249. return {
  250. value: e.id,
  251. text: e.truename,
  252. };
  253. });
  254. console.log("clrListclrListclrListclrList", clrList);
  255. },
  256. getAuth() {
  257. console.log(123123);
  258. let that = this;
  259. wx.getSetting({
  260. success(res) {
  261. // 查看所有权限
  262. let status = res.authSetting["scope.userLocation"]; // 查看位置权限的状态,此处为初次请求,所以值为undefined
  263. if (!status) {
  264. wx.openSetting({
  265. success: (res) => {
  266. if (res.authSetting["scope.userLocation"]) {
  267. // 授权成功,重新定位
  268. wx.getLocation({
  269. success: (res) => {
  270. that.getCurrentLocal();
  271. },
  272. });
  273. } else {
  274. // 没有允许定位权限
  275. wx.showToast({
  276. title: "您拒绝了定位权限,将无法使用XX功能",
  277. icon: "none",
  278. });
  279. }
  280. },
  281. });
  282. }
  283. },
  284. });
  285. },
  286. selectDengjiyuan(e) {
  287. this.form.finishUserName = e[e.length - 1].name;
  288. this.form.finishUser = e[e.length - 1].id;
  289. this.$forceUpdate();
  290. },
  291. async getSelectUserTwo(key) {
  292. let that = this;
  293. let departmentList = await getSelectUserTwo("");
  294. that.range = tools.transData(
  295. departmentList.data,
  296. "id",
  297. "parentid",
  298. "children"
  299. );
  300. console.log(key);
  301. that.$refs[key]._show();
  302. },
  303. getCurrentLocal() {
  304. let that = this;
  305. qqmapsdk.reverseGeocoder({
  306. success(res) {
  307. that.form.updateAddressX = res.result.location.lng;
  308. that.form.updateAddressY = res.result.location.lat;
  309. that.form.updateAddress =
  310. res.result.formatted_addresses.standard_address;
  311. },
  312. fail(e) {
  313. console.log(e);
  314. if (e.status == 1000) {
  315. that.$showToast(
  316. "请打开手机定位,并点击下方重新获取当前整改位置按钮"
  317. );
  318. }
  319. },
  320. });
  321. },
  322. async findSafetySelfCheckingManagetById() {
  323. let that = this;
  324. if (that.id != null) {
  325. let detail = await findSafetySelfCheckingManagetById(that.id);
  326. that.form = detail;
  327. let index =
  328. that.dic_SelectList.rectification_management_update_type.findIndex(
  329. (e) => e.value == detail.type
  330. );
  331. if (index != -1) {
  332. that.form.testTypeIndex = index;
  333. that.form.updateType =
  334. that.rectification_management_update_type[index].value;
  335. }
  336. console.log(JSON.parse(detail.infoMorePictureUrlList));
  337. that.form.infoMorePictureUrlList = JSON.parse(
  338. detail.infoMorePictureUrlList
  339. );
  340. }
  341. },
  342. selectYear(event) {
  343. this.form.attributiveYear = event.detail.value;
  344. this.$forceUpdate();
  345. },
  346. selectCarDate(event) {
  347. this.form.needFinishTime = event.detail.value;
  348. this.$forceUpdate();
  349. },
  350. bindPickerChange: function (e) {
  351. console.log("picker发送选择改变,携带值为", e.detail);
  352. this.form.testTypeIndex = e.detail.value;
  353. this.form.updateType =
  354. this.dic_SelectList.rectification_management_update_type[
  355. e.detail.value
  356. ].value;
  357. },
  358. uploadRYXXZP(event) {
  359. let that = this;
  360. const { file } = event.detail;
  361. uni.uploadFile({
  362. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  363. filePath: file.url,
  364. name: "file",
  365. formData: { user: "test" },
  366. success(res) {
  367. // 上传完成需要更新 fileList
  368. let data = JSON.parse(res.data);
  369. that.form.infoMorePictureUrlList.push({
  370. imgUrl: "/FileController/download/" + data.data[0],
  371. id: data.data[0],
  372. url:
  373. that.$constant.BASE_URI +
  374. "/FileController/download/" +
  375. data.data[0],
  376. isImage: true,
  377. });
  378. },
  379. fail(res) {},
  380. });
  381. },
  382. confirm(e) {
  383. var associationCompanyString = [];
  384. var associationCompany = [];
  385. for (var p in e) {
  386. associationCompanyString.push(e[p].label);
  387. associationCompany.push(e[p].value);
  388. }
  389. this.form.associationCompanyString = associationCompanyString.join(",");
  390. this.form.associationCompany = associationCompany.join(",");
  391. },
  392. deleteRYXXZP(event) {
  393. this.form.infoMorePictureUrlList.splice(event.detail.index, 1);
  394. this.$forceUpdate();
  395. },
  396. async getByCodes() {
  397. let data = await getByCodes(JSON.stringify(this.dic_key));
  398. this.dic_SelectList = this.$common.handleDicList(data);
  399. this.form.updateType =
  400. this.dic_SelectList.rectification_management_update_type[0].value;
  401. this.findSafetySelfCheckingManagetById();
  402. // console.log(this.form.updateType);
  403. },
  404. // /wx/SaleController/findRoomInfoListByIds
  405. async findRoomInfoListByIds() {
  406. let data = await findRoomInfoListByIds(ids);
  407. return data;
  408. },
  409. async getSelectDeptTwo(key) {
  410. let that = this;
  411. let departmentList = await getSelectDeptTwo("");
  412. that.range = tools.transData(
  413. departmentList.data,
  414. "id",
  415. "parentid",
  416. "children"
  417. );
  418. that.$refs[key]._show();
  419. },
  420. binddata() {},
  421. submit() {},
  422. async save() {
  423. let that = this;
  424. if (!that.form.finishUser || that.form.finishUser.length == 0) {
  425. that.$showToast("请选择处理人");
  426. return;
  427. }
  428. if (!that.form.info || that.form.finishUser.length == 0) {
  429. that.$showToast("请填写安全检查详情");
  430. return;
  431. }
  432. if (!that.form.updateAddress || that.form.updateAddress.length == 0) {
  433. that.$showToast(
  434. "未获取整改位置,请点击下方“重新获取当前整改位置”,确认权限后重试"
  435. );
  436. return;
  437. }
  438. // let infoMorePictureUrlList = JSON.stringify(that.form.infoMorePictureUrlList);
  439. let infoMorePictureUrl;
  440. if (that.form.infoMorePictureUrlList.length > 0) {
  441. let infoMorePictureUrlString = that.form.infoMorePictureUrlList.map(
  442. (e) => {
  443. return e.id;
  444. }
  445. );
  446. infoMorePictureUrl = infoMorePictureUrlString.toString();
  447. } else {
  448. infoMorePictureUrl = "";
  449. }
  450. let form = { ...this.form };
  451. form.finishType = this.isReport == 1 ? "2" : "1";
  452. form.infoMorePictureUrl = infoMorePictureUrl;
  453. form.openUser = getUserLocalStorageInfo().user.id;
  454. let data = await addRectificationManagement(form);
  455. if (data.code == 200) {
  456. this.$showToast("新增成功");
  457. uni.navigateBack({});
  458. } else {
  459. this.$showToast(res.msg);
  460. }
  461. },
  462. chossseFile() {
  463. this.$refs.files.upload();
  464. },
  465. onChange(event) {
  466. this.activeNames = event.detail;
  467. },
  468. },
  469. };
  470. </script>
  471. <style scoped lang="scss" scpoed>
  472. .save_button {
  473. width: calc(100% - 64rpx);
  474. margin: 64rpx 32rpx 0 32rpx;
  475. background: #1d18bc;
  476. border-radius: 50rpx;
  477. height: 88rpx;
  478. color: white;
  479. text-align: center;
  480. line-height: 88rpx;
  481. }
  482. .form {
  483. width: calc(100% - 64rpx);
  484. background: #ffffff;
  485. padding: 32rpx;
  486. margin-top: 64rpx;
  487. .label {
  488. height: 53rpx;
  489. line-height: 53rpx;
  490. }
  491. }
  492. .form_row {
  493. height: 40rpx;
  494. font-weight: 400;
  495. font-size: 24rpx;
  496. }
  497. .zaiti_list {
  498. width: 100%;
  499. height: 50rpx;
  500. line-height: 50rpx;
  501. }
  502. .idclass {
  503. width: 147rpx;
  504. height: 100rpx;
  505. }
  506. .dengjibutton {
  507. margin-top: 24rpx;
  508. margin-left: 60rpx;
  509. margin-right: 60rpx;
  510. width: calc(100% - 120rpx);
  511. height: 60rpx;
  512. text-align: center;
  513. background: #1d18bc;
  514. color: white;
  515. line-height: 60rpx;
  516. }
  517. .addcompany {
  518. margin-bottom: 200rpx;
  519. }
  520. .addcompany {
  521. .detailstitle {
  522. height: 42rpx;
  523. font-size: 30rpx;
  524. font-weight: 500;
  525. color: #333333;
  526. padding-bottom: 16rpx;
  527. }
  528. .typestitle {
  529. height: 42rpx;
  530. font-size: 24rpx;
  531. font-weight: 500;
  532. padding-bottom: 16rpx;
  533. margin-bottom: 16rpx;
  534. }
  535. }
  536. </style>
  537. <style lang="scss">
  538. ::v-deep .is-open + .uni-collapse-item__wrap {
  539. height: auto !important;
  540. }
  541. ::v-deep .uni-collapse-item__wrap-content {
  542. height: auto !important;
  543. }
  544. .addcompany {
  545. .uni-select {
  546. border: none !important;
  547. height: 40rpx !important;
  548. }
  549. }
  550. .pageconfig {
  551. background: #ffffff;
  552. padding: 32rpx;
  553. }
  554. .input_title {
  555. width: 40%;
  556. font-size: 28rpx;
  557. height: 40rpx;
  558. line-height: 40rpx;
  559. color: #333333;
  560. }
  561. .input_value {
  562. width: 60%;
  563. font-size: 28rpx;
  564. height: 40rpx;
  565. line-height: 40rpx;
  566. color: #777777;
  567. }
  568. .uni-collapse-item__title-box {
  569. padding: 0 !important;
  570. }
  571. .uni-collapse-item__title-text {
  572. color: #1d18bc !important;
  573. font-size: 32rpx !important;
  574. }
  575. </style>
  576. <style lang="scss">
  577. .example-body {
  578. padding: 10px;
  579. padding-top: 0;
  580. }
  581. .custom-image-box {
  582. /* #ifndef APP-NVUE */
  583. display: flex;
  584. /* #endif */
  585. flex-direction: row;
  586. justify-content: space-between;
  587. align-items: center;
  588. }
  589. .text {
  590. font-size: 14px;
  591. color: #333;
  592. }
  593. .uni-file-picker__item {
  594. display: none;
  595. }
  596. .uploadbutton {
  597. width: 162rpx;
  598. height: 44rpx;
  599. }
  600. </style>