add.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <template>
  2. <div class="asset_add">
  3. <div class="form gaisideshurukuang">
  4. <uni-forms
  5. ref="baseForm"
  6. style="font-size: 26rpx"
  7. :modelValue="form"
  8. label-width="170rpx"
  9. >
  10. <uni-forms-item
  11. label="走访时间:"
  12. class="mt42rpx pd42rpx border_bottom_ccc"
  13. >
  14. <div style="line-height: 73rpx">自动带出</div>
  15. </uni-forms-item>
  16. <uni-forms-item
  17. label="走访人:"
  18. class="mt42rpx pd42rpx border_bottom_ccc"
  19. >
  20. <div style="line-height: 73rpx">自动带出</div>
  21. </uni-forms-item>
  22. <uni-forms-item
  23. label="资产名称"
  24. class="mt42rpx pd42rpx border_bottom_ccc"
  25. >
  26. <div style="line-height: 73rpx">自动带出</div>
  27. </uni-forms-item>
  28. <uni-forms-item
  29. label="走访类型:"
  30. class="mt42rpx pd42rpx border_bottom_ccc"
  31. >
  32. <uni-data-checkbox
  33. selectedColor="#1d18bc"
  34. selectedTextColor="#1d18bc"
  35. multiple
  36. v-model="value"
  37. :localdata="range"
  38. @change="change"
  39. ></uni-data-checkbox>
  40. </uni-forms-item>
  41. <uni-forms-item
  42. label="资产名称"
  43. class="mt42rpx pd42rpx border_bottom_ccc"
  44. >
  45. <div style="line-height: 73rpx">
  46. <uni-data-select
  47. v-model="value"
  48. :localdata="range1"
  49. @change="change"
  50. ></uni-data-select>
  51. </div>
  52. </uni-forms-item>
  53. <uni-forms-item
  54. label="当前位置"
  55. class="mt42rpx pd42rpx border_bottom_ccc"
  56. >
  57. <div style="margin: 10rpx 0">
  58. {{ form.updateAddress ? form.updateAddress : "未知位置" }}
  59. </div>
  60. </uni-forms-item>
  61. <uni-forms-item
  62. label="任务说明"
  63. class="mt42rpx pd42rpx border_bottom_ccc"
  64. >
  65. <uni-easyinput
  66. type="textarea"
  67. autoHeight
  68. v-model="value"
  69. placeholder="请输入内容"
  70. ></uni-easyinput>
  71. </uni-forms-item>
  72. </uni-forms>
  73. </div>
  74. <div class="form">
  75. <van-row>
  76. <van-col :span="24"> 走访记录 </van-col>
  77. <van-col :span="24">
  78. <div class="margint16rpx">
  79. <uni-easyinput type="textarea" inputBorder placeholder="请输入" />
  80. </div>
  81. </van-col>
  82. </van-row>
  83. <div class="width100 mt24rpx border_bottom_ccc list_date">
  84. <div>现场照片</div>
  85. <div style="margin-top: 24rpx">(支持图片上传10M内,最多6张)</div>
  86. <div
  87. class="custom-image-box"
  88. style="margin-top: 20rpx; margin-bottom: 36rpx"
  89. >
  90. <van-uploader
  91. :max-count="6"
  92. :file-list="form.infoMorePictureUrlList"
  93. @after-read="uploadRYXXZP"
  94. :show-upload="true"
  95. />
  96. </div>
  97. </div>
  98. </div>
  99. <div class="save_button" @click="save()">提交</div>
  100. <div class="save_button" @click="getAuth()" style="margin-bottom: 20rpx">
  101. 重新获取当前整改位置
  102. </div>
  103. <van-popup :show="show" bind:close="onClose" round position="bottom">
  104. <div style="display: flex; justify-content: space-between">
  105. <div style="margin: 32rpx" @click="closePopup()">取消</div>
  106. <div style="margin: 32rpx" @click="getSelectValue()">确认</div>
  107. </div>
  108. <uni-easyinput
  109. v-model="companyName"
  110. placeholder="请输入内容"
  111. ></uni-easyinput>
  112. <picker-view
  113. indicator-style="height: 50px;"
  114. style="width: 100%; height: 300px"
  115. @change="getRowValue"
  116. :value="value"
  117. >
  118. <picker-view-column>
  119. <view
  120. v-for="(item, index) in filtedCompanyAllList()"
  121. :key="index"
  122. style="line-height: 50px; text-align: center"
  123. >{{ item.label }}</view
  124. >
  125. </picker-view-column>
  126. </picker-view>
  127. </van-popup>
  128. <!-- <view class="btn-view">
  129. <div class="btn" @click="getAuth()">重新获取当前整改位置</div>
  130. <button
  131. class="btn"
  132. @click="takeParamsGoBack(1)"
  133. style="margin-left: 10rpx"
  134. >
  135. 添加
  136. </button>
  137. </view> -->
  138. </div>
  139. </template>
  140. <script>
  141. var QQMapWX = require("./txmap_sdk/qqmap-wx-jssdk");
  142. var qqmapsdk;
  143. import {
  144. getByCodes,
  145. addInterview,
  146. getBySaveStatus,
  147. editInterview,
  148. getCompanyAll,
  149. } from "@/js_sdk/http.js";
  150. import vanRow from "../../../wxcomponents/weapp/dist/row";
  151. import vanCol from "../../../wxcomponents/weapp/dist/col";
  152. // import { findYuanQuList } from "@/js_sdk/http.js";
  153. const form = {
  154. id: null,
  155. isStatus: null,
  156. interviewTime: null,
  157. interviewType: null,
  158. interviewTypeIndex: null,
  159. companyId: null,
  160. companyIndex: null,
  161. projectType: "",
  162. interviewRecord: "",
  163. associationCompanyString: [],
  164. infoMorePictureUrlList: [],
  165. };
  166. export default {
  167. components: {
  168. vanRow,
  169. vanCol,
  170. },
  171. data() {
  172. return {
  173. range1: [
  174. { value: 0, text: "篮球" },
  175. { value: 1, text: "足球" },
  176. { value: 2, text: "游泳" },
  177. ],
  178. range: [
  179. { value: 0, text: "数据采集更新" },
  180. { value: 1, text: "预警排查" },
  181. { value: 2, text: "常规走访" },
  182. ],
  183. companyName: "",
  184. value: 0,
  185. isSelectedIndex: null,
  186. isStatus: 2,
  187. defaultSelected: [],
  188. dic_key: ["interviewType"],
  189. dic_SelectList: {},
  190. companyIndex: null,
  191. companyAllList: [],
  192. show: false,
  193. active: 0,
  194. form: { ...form },
  195. index: 0,
  196. BASE_URI: this.$constant.BASE_URI,
  197. };
  198. },
  199. computed: {},
  200. mounted() {
  201. this.getCompanyAll();
  202. this.getByCodes();
  203. qqmapsdk = new QQMapWX({
  204. key: "OJ7BZ-ULH6V-XBLPV-ULIMK-APS3H-QHFIP",
  205. });
  206. this.getCurrentLocal();
  207. },
  208. methods: {
  209. getCurrentLocal() {
  210. let that = this;
  211. qqmapsdk.reverseGeocoder({
  212. success(res) {
  213. console.log(res.result.formatted_addresses.standard_address);
  214. that.form.updateAddressX = res.result.location.lng;
  215. that.form.updateAddressY = res.result.location.lat;
  216. that.form.updateAddress =
  217. res.result.formatted_addresses.standard_address;
  218. that.$forceUpdate();
  219. },
  220. fail(e) {
  221. console.log(e);
  222. if (e.status == 1000) {
  223. that.$showToast(
  224. "请打开手机定位,并点击下方重新获取当前整改位置按钮"
  225. );
  226. }
  227. },
  228. });
  229. },
  230. getAuth() {
  231. console.log(123123);
  232. let that = this;
  233. wx.getSetting({
  234. success(res) {
  235. // 查看所有权限
  236. let status = res.authSetting["scope.userLocation"]; // 查看位置权限的状态,此处为初次请求,所以值为undefined
  237. if (!status) {
  238. wx.openSetting({
  239. success: (res) => {
  240. if (res.authSetting["scope.userLocation"]) {
  241. // 授权成功,重新定位
  242. wx.getLocation({
  243. success: (res) => {
  244. that.getCurrentLocal();
  245. },
  246. });
  247. } else {
  248. // 没有允许定位权限
  249. wx.showToast({
  250. title: "您拒绝了定位权限,将无法使用XX功能",
  251. icon: "none",
  252. });
  253. }
  254. },
  255. });
  256. }
  257. },
  258. });
  259. },
  260. uploadRYXXZP(event) {
  261. let that = this;
  262. const { file } = event.detail;
  263. uni.uploadFile({
  264. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  265. filePath: file.url,
  266. name: "file",
  267. formData: { user: "test" },
  268. success(res) {
  269. // 上传完成需要更新 fileList
  270. let data = JSON.parse(res.data);
  271. that.form.infoMorePictureUrlList.push({
  272. imgUrl: "/FileController/download/" + data.data[0],
  273. id: data.data[0],
  274. url:
  275. that.$constant.BASE_URI +
  276. "/FileController/download/" +
  277. data.data[0],
  278. isImage: true,
  279. });
  280. },
  281. fail(res) {},
  282. });
  283. },
  284. closePopup() {
  285. this.show = false;
  286. this.form.companyIndex = null;
  287. this.form.companyId = null;
  288. },
  289. filtedCompanyAllList() {
  290. let companyAllList;
  291. if (this.companyName && this.companyName.length > 0) {
  292. companyAllList = this.companyAllList.filter((e) =>
  293. e.label.includes(this.companyName)
  294. );
  295. if (companyAllList.length > 0 && companyAllList[0].value) {
  296. let index = this.companyAllList.findIndex(
  297. (e) => e.value == companyAllList[0].value
  298. );
  299. this.form.companyIndex = index;
  300. this.form.companyId =
  301. this.companyAllList[this.form.companyIndex].value;
  302. } else {
  303. this.form.companyIndex = null;
  304. this.form.companyId = null;
  305. }
  306. } else {
  307. companyAllList = this.companyAllList;
  308. }
  309. console.log(companyAllList);
  310. return companyAllList;
  311. },
  312. getRowValue(e) {
  313. this.isSelectedIndex = e.detail.value[0];
  314. },
  315. getSelectValue() {
  316. console.log(this.value);
  317. if (this.isSelectedIndex == null) {
  318. this.form.companyIndex = 0;
  319. this.form.companyId = this.companyAllList[0].value;
  320. } else {
  321. this.form.companyIndex = this.isSelectedIndex;
  322. this.form.companyId = this.companyAllList[this.form.companyIndex].value;
  323. }
  324. this.$forceUpdate();
  325. this.show = false;
  326. },
  327. changeLog(e) {},
  328. async getBySaveStatus() {
  329. const token = uni.getStorageSync("laocui_user_info");
  330. let data = await getBySaveStatus(JSON.parse(token).user.id);
  331. this.form.id = data.id ? data.id : null;
  332. this.form.isStatus = Number(data.isStatus);
  333. this.form.interviewTime = data.interviewTime ? data.interviewTime : "";
  334. this.form.interviewRecord = data.interviewRecord
  335. ? data.interviewRecord
  336. : "";
  337. if (
  338. data.id &&
  339. data.interviewType != null &&
  340. data.interviewType != "null"
  341. ) {
  342. this.getInterviewLableByApiList(data);
  343. }
  344. if (data.id && data.companyId != null) {
  345. this.getCompanyIdByApiList(data);
  346. }
  347. },
  348. getCompanyIdByApiList(params) {
  349. this.form.companyId = params.companyId;
  350. console.log(
  351. "this.companyAllListthis.companyAllListthis.companyAllList",
  352. this.companyAllList
  353. );
  354. let companyIndex = this.companyAllList.findIndex(
  355. (e) => e.value == params.companyId
  356. );
  357. this.form.companyIndex = companyIndex;
  358. },
  359. getInterviewLableByApiList(params) {
  360. let interviewTypeIndex = this.dic_SelectList.interviewType.findIndex(
  361. (e) => e.value == params.interviewType
  362. );
  363. this.form.interviewType =
  364. this.dic_SelectList.interviewType[interviewTypeIndex].value;
  365. this.form.interviewTypeIndex = interviewTypeIndex;
  366. },
  367. getInterviewTime(e) {
  368. this.form.interviewTime = e.detail.value;
  369. },
  370. async takeParamsGoBack(e) {
  371. const token = uni.getStorageSync("laocui_user_info");
  372. let data;
  373. if (e == 1) {
  374. if (this.form.companyId == null) {
  375. return this.$showToast("请选择走访公司");
  376. }
  377. if (this.form.interviewTime == null || this.form.interviewTime == "") {
  378. return this.$showToast("请选择走访时间");
  379. }
  380. if (this.form.interviewType == null) {
  381. return this.$showToast("请选择走访类型");
  382. }
  383. if (this.form.isStatus == null) {
  384. return this.$showToast("请选择是否需要处理");
  385. }
  386. }
  387. if (e == 0) {
  388. data = await editInterview({
  389. ...this.form,
  390. status: e,
  391. createdBy: JSON.parse(token).user.id,
  392. InterviewUserId: JSON.parse(token).user.id,
  393. });
  394. } else {
  395. data = await addInterview({
  396. ...this.form,
  397. status: e,
  398. createdBy: JSON.parse(token).user.id,
  399. InterviewUserId: JSON.parse(token).user.id,
  400. });
  401. }
  402. if (data.code == 200) {
  403. if (e == 1) {
  404. this.$emit("changeActive");
  405. this.$showToast("提交成功");
  406. this.form = { ...form };
  407. }
  408. if (e == 0) {
  409. this.$showToast("保存成功");
  410. }
  411. }
  412. },
  413. getCompany(e) {
  414. this.form.companyIndex = e.detail.value;
  415. this.form.companyId = this.companyAllList[e.detail.value].value;
  416. },
  417. chosseAboutCompany() {
  418. this.show = true;
  419. // this.$refs.popup.open('top')
  420. },
  421. async getCompanyAll() {
  422. let companyAllList = await getCompanyAll();
  423. this.companyAllList = companyAllList.map((e) => {
  424. return {
  425. label: e.qymc,
  426. value: e.id,
  427. };
  428. });
  429. this.getBySaveStatus();
  430. },
  431. async getByCodes() {
  432. let data = await getByCodes(JSON.stringify(this.dic_key));
  433. this.dic_SelectList = this.$common.handleDicList(data);
  434. this.dic_SelectList.interviewType[0].id;
  435. },
  436. confirm(e) {
  437. let associationCompanyString = [];
  438. let associationCompany = [];
  439. for (var p in e) {
  440. associationCompanyString.push(e[p].label);
  441. associationCompany.push(e[p].value);
  442. }
  443. this.form.associationCompanyString = associationCompanyString.join(",");
  444. this.form.associationCompany = associationCompany.join(",");
  445. },
  446. bindPickerChange(e) {
  447. this.form.interviewTypeIndex = e.detail.value;
  448. this.form.interviewType =
  449. this.dic_SelectList.interviewType[e.detail.value].value;
  450. },
  451. },
  452. // onLoad: function (){
  453. // this.$refs.findYuanQuList()
  454. // },
  455. };
  456. </script>
  457. <style lang="scss">
  458. .save_button {
  459. width: calc(100% - 64rpx);
  460. margin: 32rpx;
  461. background: #1d18bc;
  462. border-radius: 50rpx;
  463. height: 88rpx;
  464. color: white;
  465. text-align: center;
  466. line-height: 88rpx;
  467. }
  468. .btn-view {
  469. width: 100%;
  470. height: 100rpx;
  471. padding: 20rpx 10%;
  472. background-color: #ffffff;
  473. position: fixed;
  474. bottom: 0;
  475. left: 0;
  476. }
  477. .btn {
  478. width: 80%;
  479. height: 90rpx;
  480. border-radius: 8rpx 8rpx 8rpx 8rpx;
  481. background: #1d18bc;
  482. line-height: 90rpx;
  483. color: white;
  484. float: left;
  485. }
  486. .gaisideshurukuang {
  487. font-size: 26rpx !important;
  488. .is-input-border {
  489. border-top: none !important;
  490. border-left: none !important;
  491. border-right: none !important;
  492. border: none;
  493. border-radius: 0 !important;
  494. }
  495. }
  496. .asset_add {
  497. .uni-select {
  498. border: none;
  499. }
  500. .textarea_info {
  501. textarea {
  502. background: #f9f9f9;
  503. }
  504. }
  505. .form {
  506. width: calc(100% - 128rpx);
  507. margin: 32rpx;
  508. background: #ffffff;
  509. padding: 32rpx;
  510. .label {
  511. height: 53rpx;
  512. line-height: 53rpx;
  513. }
  514. .is-input-border {
  515. border-top: none !important;
  516. border-left: none !important;
  517. border-right: none !important;
  518. border-radius: 0 !important;
  519. }
  520. .uni-forms-item {
  521. margin-bottom: 10rpx !important;
  522. margin-top: 10rpx !important;
  523. border-bottom: 2rpx solid #cccccc !important;
  524. // margin-top: 42rpx !important;
  525. // padding-bottom: 42rpx !important;
  526. }
  527. }
  528. }
  529. </style>