add.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <div class="repair-box">
  3. <div class="repair-content fixed-page-content">
  4. <div class="white-box page-1">
  5. <div class="page-1-head" @click="goNavigator('repairprocessing-app')">
  6. <i class="iconfont icon-daichulihetong"></i>
  7. <span>处理记录</span>
  8. </div>
  9. </div>
  10. <div class="white-box page-2">
  11. <div class="custom-item-tit">
  12. <p class="tit">当前企业</p>
  13. </div>
  14. <div class="custom-white-box-content">
  15. <div class="custom-input-box">
  16. <input
  17. type="text"
  18. maxlength="50px"
  19. placeholder="请输入"
  20. v-model="companyName"
  21. />
  22. </div>
  23. </div>
  24. <div class="cell-item">
  25. <p class="label required">您是想</p>
  26. <div class="tit">
  27. <van-radio-group v-model="form.type">
  28. <van-radio name="1" checked-color="#976CEB">报事</van-radio>
  29. <van-radio name="2" checked-color="#976CEB">咨询</van-radio>
  30. </van-radio-group>
  31. </div>
  32. </div>
  33. <div class="block-cell-item">
  34. <p class="label">快捷选择</p>
  35. <div class="tit">
  36. <ul class="custom-select-list">
  37. <li
  38. v-for="item in quickList"
  39. v-if="item.value !== ''"
  40. :key="item.value"
  41. :class="{
  42. active: quickSleced.value && item.value === quickSleced.value,
  43. }"
  44. @click="quickSelect(item)"
  45. >
  46. {{ item.label }}
  47. </li>
  48. </ul>
  49. <van-field
  50. v-model="form.description"
  51. rows="4"
  52. autosize
  53. type="textarea"
  54. maxlength="800"
  55. placeholder="输入文字进行报事报修描述"
  56. show-word-limit
  57. >
  58. </van-field>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="white-box page-3">
  63. <div class="cell-item">
  64. <p class="label required">位置</p>
  65. <div class="tit">
  66. <van-radio-group v-model="form.position">
  67. <van-radio
  68. :name="item.val"
  69. checked-color="#976CEB"
  70. v-for="item in positionList"
  71. :key="item.val"
  72. @change="changePosition(item.val)"
  73. >{{ item.label }}</van-radio
  74. >
  75. </van-radio-group>
  76. </div>
  77. </div>
  78. <div class="block-cell-item">
  79. <p class="label">
  80. 补充说明<span class="tips"
  81. >(支持图片/视频上传限20M内,最多6张)</span
  82. >
  83. </p>
  84. <div class="tit">
  85. <van-uploader
  86. :multiple="true"
  87. v-model="fileUrls"
  88. :max-count="6"
  89. :after-read="afterRead"
  90. :before-delete="beforeDelete"
  91. >
  92. </van-uploader>
  93. </div>
  94. </div>
  95. <div class="cell-item">
  96. <p class="label">报事人</p>
  97. <p class="tit">{{ form.userId }}</p>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="repair-bottom bottom-button">
  102. <button class="btn" @click="submit">提交</button>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. import Base from "@/pages/base/base";
  108. import axios from "axios";
  109. import { add } from "../../service/api_repair";
  110. import { getCompanyById } from "@/service/api_road_show";
  111. import { Toast } from "vant";
  112. import auth from "@/service/auth";
  113. export default {
  114. data() {
  115. return {
  116. dc_key: ["QUICK_SELECTION"],
  117. reportTypeSleced: "1",
  118. quickSleced: {},
  119. quickList: [
  120. // {
  121. // value: '1',
  122. // label: '挂件安装'
  123. // },
  124. // {
  125. // value: '2',
  126. // label: '我要投诉'
  127. // },
  128. // {
  129. // value: '3',
  130. // label: '疏通管道'
  131. // },
  132. // {
  133. // value: '4',
  134. // label: '维修线路'
  135. // },
  136. // {
  137. // value: '5',
  138. // label: '更换灯泡'
  139. // },
  140. // {
  141. // value: '6',
  142. // label: '网络维修'
  143. // },
  144. // {
  145. // value: '7',
  146. // label: '保洁服务'
  147. // },
  148. // {
  149. // value: '8',
  150. // label: '其它维修'
  151. // }
  152. ],
  153. positionSleced: "1",
  154. positionList: [
  155. {
  156. val: "1",
  157. label: "室内",
  158. },
  159. {
  160. val: "2",
  161. label: "公区",
  162. },
  163. ],
  164. fileUrlList: [],
  165. fileUrls: [],
  166. companyName: "",
  167. form: {
  168. groupId: "",
  169. companyId: "",
  170. type: "1",
  171. serviceType: "",
  172. description: "",
  173. position: "1",
  174. userId: auth.currUser().truename + "-" + auth.currUser().phone,
  175. fileUrl: "",
  176. status: "unAcceptance",
  177. },
  178. };
  179. },
  180. mixins: [Base],
  181. mounted() {
  182. this.initDict(this.dc_key).then((res) => {
  183. this.quickList = this.dc_data.QUICK_SELECTION;
  184. });
  185. getCompanyById({ id: auth.currUser().id, type: "2,3" }).then((res) => {
  186. this.form.companyId = res.data.id;
  187. this.companyName = res.data.businessName;
  188. });
  189. },
  190. methods: {
  191. /**
  192. *
  193. */
  194. quickSelect(item) {
  195. if (this.quickSleced.value && this.quickSleced.value === item.value) {
  196. this.quickSleced = {};
  197. } else {
  198. this.quickSleced = item;
  199. }
  200. },
  201. /**
  202. * 上传文件
  203. */
  204. afterRead(file) {
  205. if (file instanceof Array) {
  206. file.map((v) => {
  207. this.uploadImg(v);
  208. });
  209. } else {
  210. this.uploadImg(file);
  211. }
  212. },
  213. beforeDelete(file, detail) {
  214. // this.handleImagUrlList = []
  215. const vm = this;
  216. // name.index代表图片的索引
  217. vm.fileUrlList.splice(detail.index, 1);
  218. return (file, name) => {
  219. const fileIndex = name.index;
  220. vm.fileUrlList[detail.index].splice(fileIndex, 1);
  221. };
  222. },
  223. /**
  224. * 上传图片
  225. */
  226. uploadImg(file) {
  227. const _this = this;
  228. const formParam = new FormData(); // 创建form对象
  229. formParam.append("file", file.file); // 通过append向form对象添加数据
  230. console.log(formParam.get("file")); // FormData私有类对象,访问不到,可以通过get判断值是否传进去
  231. // upload(formParam).then((res) => {
  232. //
  233. // })
  234. const config = {
  235. headers: {
  236. "Content-Type": "multipart/form-data",
  237. "MVVM-Key": String(new Date().getTime()),
  238. xx: "anything",
  239. }, // 这里是重点,需要和后台沟通好请求头,Content-Type不一定是这个值
  240. }; // 添加请求头
  241. return new Promise((resolve, reject) => {
  242. axios
  243. .post(
  244. "/smartParkH5Server/wx/fileController/upload",
  245. formParam,
  246. config
  247. )
  248. .then((response) => {
  249. let files = response.data.data.substring(
  250. 1,
  251. response.data.data.length
  252. );
  253. files = files.substring(0, files.length - 1);
  254. _this.fileUrlList.push(_this.$common.castEval(files));
  255. })
  256. .catch((err, x) => {
  257. reject(err, x);
  258. });
  259. });
  260. },
  261. submit() {
  262. if (this.quickSleced.value == null || this.quickSleced.value === "") {
  263. Toast("请选择服务类型");
  264. return;
  265. }
  266. this.form.groupId = ""; // 园区
  267. this.form.fileUrl = JSON.stringify(this.fileUrlList);
  268. this.form.userId =
  269. auth.currUser().id +
  270. "-" +
  271. auth.currUser().truename +
  272. "-" +
  273. auth.currUser().phone;
  274. this.form.companyName = this.companyName;
  275. this.form.serviceType = this.quickSleced.value;
  276. this.form.createdBy = auth.currUser().id;
  277. add(this.form).then((res) => {
  278. Toast("填报成功");
  279. this.$router.push({
  280. path: "/repairprocessing-app",
  281. });
  282. });
  283. },
  284. changePosition(val) {},
  285. },
  286. };
  287. </script>
  288. <style lang="scss" scoped>
  289. .repair-box {
  290. width: 100%;
  291. height: 100%;
  292. .page-1 {
  293. font-size: 30px;
  294. color: var(--violetColor2);
  295. padding: 30px;
  296. box-sizing: border-box;
  297. .page-1-head {
  298. display: flex;
  299. align-items: center;
  300. justify-content: flex-end;
  301. i {
  302. font-size: 38px;
  303. margin-right: 10px;
  304. }
  305. }
  306. }
  307. .page-2 {
  308. .van-cell {
  309. padding: 20px;
  310. border-radius: 10px;
  311. background: $page-color-base;
  312. box-sizing: border-box;
  313. textarea {
  314. height: 60px;
  315. }
  316. }
  317. }
  318. }
  319. </style>