add.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. <uni-easyinput
  46. type="textarea"
  47. autoHeight
  48. v-model="value"
  49. placeholder="请输入内容"
  50. ></uni-easyinput>
  51. </uni-forms-item>
  52. </uni-forms>
  53. </div>
  54. <div class="form" style="margin-bottom: 146rpx">
  55. <van-row>
  56. <van-col :span="24"> 走访记录 </van-col>
  57. <van-col :span="24">
  58. <div class="margint16rpx">
  59. <uni-easyinput type="textarea" inputBorder placeholder="请输入" />
  60. </div>
  61. </van-col>
  62. </van-row>
  63. <div class="width100 mt24rpx border_bottom_ccc list_date">
  64. <div>现场照片</div>
  65. <div style="margin-top: 24rpx">(支持图片上传10M内,最多6张)</div>
  66. <div
  67. class="custom-image-box"
  68. style="margin-top: 20rpx; margin-bottom: 36rpx"
  69. >
  70. <van-uploader
  71. :max-count="6"
  72. :file-list="form.infoMorePictureUrlList"
  73. @after-read="uploadRYXXZP"
  74. :show-upload="true"
  75. />
  76. </div>
  77. </div>
  78. </div>
  79. <van-popup :show="show" bind:close="onClose" round position="bottom">
  80. <div style="display: flex; justify-content: space-between">
  81. <div style="margin: 32rpx" @click="closePopup()">取消</div>
  82. <div style="margin: 32rpx" @click="getSelectValue()">确认</div>
  83. </div>
  84. <uni-easyinput
  85. v-model="companyName"
  86. placeholder="请输入内容"
  87. ></uni-easyinput>
  88. <picker-view
  89. indicator-style="height: 50px;"
  90. style="width: 100%; height: 300px"
  91. @change="getRowValue"
  92. :value="value"
  93. >
  94. <picker-view-column>
  95. <view
  96. v-for="(item, index) in filtedCompanyAllList()"
  97. :key="index"
  98. style="line-height: 50px; text-align: center"
  99. >{{ item.label }}</view
  100. >
  101. </picker-view-column>
  102. </picker-view>
  103. </van-popup>
  104. <view class="btn-view">
  105. <button class="btn" @click="takeParamsGoBack(0)">保存</button>
  106. <button
  107. class="btn"
  108. @click="takeParamsGoBack(1)"
  109. style="margin-left: 10rpx"
  110. >
  111. 添加
  112. </button>
  113. </view>
  114. </div>
  115. </template>
  116. <script>
  117. import {
  118. getByCodes,
  119. addInterview,
  120. getBySaveStatus,
  121. editInterview,
  122. getCompanyAll,
  123. } from "@/js_sdk/http.js";
  124. import vanRow from "../../../wxcomponents/weapp/dist/row";
  125. import vanCol from "../../../wxcomponents/weapp/dist/col";
  126. // import { findYuanQuList } from "@/js_sdk/http.js";
  127. const form = {
  128. id: null,
  129. isStatus: null,
  130. interviewTime: null,
  131. interviewType: null,
  132. interviewTypeIndex: null,
  133. companyId: null,
  134. companyIndex: null,
  135. projectType: "",
  136. interviewRecord: "",
  137. associationCompanyString: [],
  138. infoMorePictureUrlList: [],
  139. };
  140. export default {
  141. components: {
  142. vanRow,
  143. vanCol,
  144. },
  145. data() {
  146. return {
  147. range: [
  148. { value: 0, text: "数据采集更新" },
  149. { value: 1, text: "预警排查" },
  150. { value: 2, text: "常规走访" },
  151. ],
  152. companyName: "",
  153. value: 0,
  154. isSelectedIndex: null,
  155. isStatus: 2,
  156. defaultSelected: [],
  157. dic_key: ["interviewType"],
  158. dic_SelectList: {},
  159. companyIndex: null,
  160. companyAllList: [],
  161. show: false,
  162. active: 0,
  163. form: { ...form },
  164. index: 0,
  165. BASE_URI: this.$constant.BASE_URI,
  166. };
  167. },
  168. computed: {},
  169. mounted() {
  170. this.getCompanyAll();
  171. this.getByCodes();
  172. },
  173. methods: {
  174. uploadRYXXZP(event) {
  175. let that = this;
  176. const { file } = event.detail;
  177. uni.uploadFile({
  178. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  179. filePath: file.url,
  180. name: "file",
  181. formData: { user: "test" },
  182. success(res) {
  183. // 上传完成需要更新 fileList
  184. let data = JSON.parse(res.data);
  185. that.form.infoMorePictureUrlList.push({
  186. imgUrl: "/FileController/download/" + data.data[0],
  187. id: data.data[0],
  188. url:
  189. that.$constant.BASE_URI +
  190. "/FileController/download/" +
  191. data.data[0],
  192. isImage: true,
  193. });
  194. },
  195. fail(res) {},
  196. });
  197. },
  198. closePopup() {
  199. this.show = false;
  200. this.form.companyIndex = null;
  201. this.form.companyId = null;
  202. },
  203. filtedCompanyAllList() {
  204. let companyAllList;
  205. if (this.companyName && this.companyName.length > 0) {
  206. companyAllList = this.companyAllList.filter((e) =>
  207. e.label.includes(this.companyName)
  208. );
  209. if (companyAllList.length > 0 && companyAllList[0].value) {
  210. let index = this.companyAllList.findIndex(
  211. (e) => e.value == companyAllList[0].value
  212. );
  213. this.form.companyIndex = index;
  214. this.form.companyId =
  215. this.companyAllList[this.form.companyIndex].value;
  216. } else {
  217. this.form.companyIndex = null;
  218. this.form.companyId = null;
  219. }
  220. } else {
  221. companyAllList = this.companyAllList;
  222. }
  223. console.log(companyAllList);
  224. return companyAllList;
  225. },
  226. getRowValue(e) {
  227. this.isSelectedIndex = e.detail.value[0];
  228. },
  229. getSelectValue() {
  230. console.log(this.value);
  231. if (this.isSelectedIndex == null) {
  232. this.form.companyIndex = 0;
  233. this.form.companyId = this.companyAllList[0].value;
  234. } else {
  235. this.form.companyIndex = this.isSelectedIndex;
  236. this.form.companyId = this.companyAllList[this.form.companyIndex].value;
  237. }
  238. this.$forceUpdate();
  239. this.show = false;
  240. },
  241. changeLog(e) {},
  242. async getBySaveStatus() {
  243. const token = uni.getStorageSync("laocui_user_info");
  244. let data = await getBySaveStatus(JSON.parse(token).user.id);
  245. this.form.id = data.id ? data.id : null;
  246. this.form.isStatus = Number(data.isStatus);
  247. this.form.interviewTime = data.interviewTime ? data.interviewTime : "";
  248. this.form.interviewRecord = data.interviewRecord
  249. ? data.interviewRecord
  250. : "";
  251. if (
  252. data.id &&
  253. data.interviewType != null &&
  254. data.interviewType != "null"
  255. ) {
  256. this.getInterviewLableByApiList(data);
  257. }
  258. if (data.id && data.companyId != null) {
  259. this.getCompanyIdByApiList(data);
  260. }
  261. },
  262. getCompanyIdByApiList(params) {
  263. this.form.companyId = params.companyId;
  264. console.log(
  265. "this.companyAllListthis.companyAllListthis.companyAllList",
  266. this.companyAllList
  267. );
  268. let companyIndex = this.companyAllList.findIndex(
  269. (e) => e.value == params.companyId
  270. );
  271. this.form.companyIndex = companyIndex;
  272. },
  273. getInterviewLableByApiList(params) {
  274. let interviewTypeIndex = this.dic_SelectList.interviewType.findIndex(
  275. (e) => e.value == params.interviewType
  276. );
  277. this.form.interviewType =
  278. this.dic_SelectList.interviewType[interviewTypeIndex].value;
  279. this.form.interviewTypeIndex = interviewTypeIndex;
  280. },
  281. getInterviewTime(e) {
  282. this.form.interviewTime = e.detail.value;
  283. },
  284. async takeParamsGoBack(e) {
  285. const token = uni.getStorageSync("laocui_user_info");
  286. let data;
  287. if (e == 1) {
  288. if (this.form.companyId == null) {
  289. return this.$showToast("请选择走访公司");
  290. }
  291. if (this.form.interviewTime == null || this.form.interviewTime == "") {
  292. return this.$showToast("请选择走访时间");
  293. }
  294. if (this.form.interviewType == null) {
  295. return this.$showToast("请选择走访类型");
  296. }
  297. if (this.form.isStatus == null) {
  298. return this.$showToast("请选择是否需要处理");
  299. }
  300. }
  301. if (e == 0) {
  302. data = await editInterview({
  303. ...this.form,
  304. status: e,
  305. createdBy: JSON.parse(token).user.id,
  306. InterviewUserId: JSON.parse(token).user.id,
  307. });
  308. } else {
  309. data = await addInterview({
  310. ...this.form,
  311. status: e,
  312. createdBy: JSON.parse(token).user.id,
  313. InterviewUserId: JSON.parse(token).user.id,
  314. });
  315. }
  316. if (data.code == 200) {
  317. if (e == 1) {
  318. this.$emit("changeActive");
  319. this.$showToast("提交成功");
  320. this.form = { ...form };
  321. }
  322. if (e == 0) {
  323. this.$showToast("保存成功");
  324. }
  325. }
  326. },
  327. getCompany(e) {
  328. this.form.companyIndex = e.detail.value;
  329. this.form.companyId = this.companyAllList[e.detail.value].value;
  330. },
  331. chosseAboutCompany() {
  332. this.show = true;
  333. // this.$refs.popup.open('top')
  334. },
  335. async getCompanyAll() {
  336. let companyAllList = await getCompanyAll();
  337. this.companyAllList = companyAllList.map((e) => {
  338. return {
  339. label: e.qymc,
  340. value: e.id,
  341. };
  342. });
  343. this.getBySaveStatus();
  344. },
  345. async getByCodes() {
  346. let data = await getByCodes(JSON.stringify(this.dic_key));
  347. this.dic_SelectList = this.$common.handleDicList(data);
  348. this.dic_SelectList.interviewType[0].id;
  349. },
  350. confirm(e) {
  351. let associationCompanyString = [];
  352. let associationCompany = [];
  353. for (var p in e) {
  354. associationCompanyString.push(e[p].label);
  355. associationCompany.push(e[p].value);
  356. }
  357. this.form.associationCompanyString = associationCompanyString.join(",");
  358. this.form.associationCompany = associationCompany.join(",");
  359. },
  360. bindPickerChange(e) {
  361. this.form.interviewTypeIndex = e.detail.value;
  362. this.form.interviewType =
  363. this.dic_SelectList.interviewType[e.detail.value].value;
  364. },
  365. },
  366. // onLoad: function (){
  367. // this.$refs.findYuanQuList()
  368. // },
  369. };
  370. </script>
  371. <style lang="scss">
  372. .btn-view {
  373. width: 100%;
  374. height: 100rpx;
  375. padding: 20rpx 10%;
  376. background-color: #ffffff;
  377. position: fixed;
  378. bottom: 0;
  379. left: 0;
  380. }
  381. .btn {
  382. width: 40%;
  383. height: 90rpx;
  384. border-radius: 8rpx 8rpx 8rpx 8rpx;
  385. background: #1d18bc;
  386. line-height: 90rpx;
  387. color: white;
  388. float: left;
  389. }
  390. .gaisideshurukuang {
  391. font-size: 26rpx !important;
  392. .is-input-border {
  393. border-top: none !important;
  394. border-left: none !important;
  395. border-right: none !important;
  396. border: none;
  397. border-radius: 0 !important;
  398. }
  399. }
  400. .asset_add {
  401. .textarea_info {
  402. textarea {
  403. background: #f9f9f9;
  404. }
  405. }
  406. .form {
  407. width: calc(100% - 128rpx);
  408. margin: 32rpx;
  409. background: #ffffff;
  410. padding: 32rpx;
  411. .label {
  412. height: 53rpx;
  413. line-height: 53rpx;
  414. }
  415. .is-input-border {
  416. border-top: none !important;
  417. border-left: none !important;
  418. border-right: none !important;
  419. border-radius: 0 !important;
  420. }
  421. .uni-forms-item {
  422. margin-bottom: 10rpx !important;
  423. margin-top: 10rpx !important;
  424. border-bottom: 2rpx solid #cccccc !important;
  425. // margin-top: 42rpx !important;
  426. // padding-bottom: 42rpx !important;
  427. }
  428. }
  429. }
  430. </style>