CarDataEdit.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <div v-loading="loading" element-loading-text="跳转中...">
  3. <div class="communal-title">
  4. <div>修改车公司资料</div>
  5. </div>
  6. <template>
  7. <el-form :model="upData" :rules="rules" ref="upData" label-width="100px" class="demo-ruleForm">
  8. <el-row>
  9. <el-col :span="8">
  10. <el-form-item label="服务评分" prop="Score">
  11. <el-select v-model="upData.Score" placeholder="服务评分">
  12. <el-option key="1" label="1分" value="1"></el-option>
  13. <el-option key="2" label="2分" value="2"></el-option>
  14. <el-option key="3" label="3分" value="3"></el-option>
  15. <el-option key="4" label="4分" value="4"></el-option>
  16. <el-option key="5" label="5分" value="5"></el-option>
  17. </el-select>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="8">
  21. <el-form-item label="单位地区" prop="UnitArea">
  22. <el-autocomplete class="inline-input" v-model="upData.UnitArea" :fetch-suggestions="querySearch"
  23. placeholder="请输入单位地区" @select="handleSelect" style="width: 290px;"></el-autocomplete>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="8">
  27. <el-form-item label="单位名称" prop="UnitName">
  28. <el-input placeholder="单位名称" v-model="upData.UnitName">
  29. </el-input>
  30. </el-form-item>
  31. </el-col>
  32. </el-row>
  33. <el-row>
  34. <el-col :span="24">
  35. <el-form-item label="单位地址" prop="Address">
  36. <el-input placeholder="单位地址" v-model="upData.Address">
  37. </el-input>
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. <el-row>
  42. <el-col :span="8">
  43. <el-form-item label="联系人" prop="Contact">
  44. <el-input placeholder="单位地址" v-model="upData.Contact">
  45. </el-input>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="8">
  49. <el-form-item label="联系方式" prop="ContactTel">
  50. <el-input placeholder="联系方式" v-model="upData.ContactTel">
  51. </el-input>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="8">
  55. <el-form-item label="电子邮箱" prop="ContactEmail">
  56. <el-input placeholder="电子邮箱" v-model="upData.ContactEmail">
  57. </el-input>
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. <el-row>
  62. <el-col :span="8">
  63. <el-form-item label="传 真" prop="ContactFax">
  64. <el-input placeholder="传 真" v-model="upData.ContactFax">
  65. </el-input>
  66. </el-form-item>
  67. </el-col>
  68. </el-row>
  69. <el-row>
  70. <el-col :span="23">
  71. <el-form-item label="其他信息" prop="OtherInfo">
  72. <el-input type="textarea" :rows="3" placeholder="请输入内容" v-model="upData.OtherInfo"
  73. style="width: 80%;"></el-input>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. <el-row>
  78. <el-col :span="6">
  79. <el-form-item label="有相关的车辆资质" prop="QualificationScore" label-width="130px">
  80. <template>
  81. <el-radio v-model="upData.QualificationScore" label="A"
  82. style="margin-right: 10px">A</el-radio>
  83. <el-radio v-model="upData.QualificationScore" label="B"
  84. style="margin-right: 10px">B</el-radio>
  85. <el-radio v-model="upData.QualificationScore" label="C"
  86. style="margin-right: 10px">C</el-radio>
  87. </template>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="9">
  91. <el-form-item label="车辆2-4年新,VIP及以上需要2年新" prop="CarAgeScore" label-width="260px">
  92. <template>
  93. <el-radio v-model="upData.CarAgeScore" label="A" style="margin-right: 10px">A</el-radio>
  94. <el-radio v-model="upData.CarAgeScore" label="B" style="margin-right: 10px">B</el-radio>
  95. <el-radio v-model="upData.CarAgeScore" label="C" style="margin-right: 10px">C</el-radio>
  96. </template>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="9">
  100. <el-form-item label="车身干净,无文字图片等" prop="CleanImgScore" label-width="170px">
  101. <template>
  102. <el-radio v-model="upData.CleanImgScore" label="A" style="margin-right: 10px">A</el-radio>
  103. <el-radio v-model="upData.CleanImgScore" label="B" style="margin-right: 10px">B</el-radio>
  104. <el-radio v-model="upData.CleanImgScore" label="C" style="margin-right: 10px">C</el-radio>
  105. </template>
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <el-row>
  110. <el-col :span="6">
  111. <el-form-item label="车内整洁、无异味" prop="SmellScore" label-width="130px">
  112. <template>
  113. <el-radio v-model="upData.SmellScore" label="A" style="margin-right: 10px">A</el-radio>
  114. <el-radio v-model="upData.SmellScore" label="B" style="margin-right: 10px">B</el-radio>
  115. <el-radio v-model="upData.SmellScore" label="C" style="margin-right: 10px">C</el-radio>
  116. </template>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="9">
  120. <el-form-item label="提前备水,纸巾等" prop="WaterPaperScore" label-width="260px">
  121. <template>
  122. <el-radio v-model="upData.WaterPaperScore" label="A" style="margin-right: 10px">A</el-radio>
  123. <el-radio v-model="upData.WaterPaperScore" label="B" style="margin-right: 10px">B</el-radio>
  124. <el-radio v-model="upData.WaterPaperScore" label="C" style="margin-right: 10px">C</el-radio>
  125. </template>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="9">
  129. <el-form-item label="车辆配置高(皮座椅等)" prop="HardwareScore" label-width="170px">
  130. <template>
  131. <el-radio v-model="upData.HardwareScore" label="A" style="margin-right: 10px">A</el-radio>
  132. <el-radio v-model="upData.HardwareScore" label="B" style="margin-right: 10px">B</el-radio>
  133. <el-radio v-model="upData.HardwareScore" label="C" style="margin-right: 10px">C</el-radio>
  134. </template>
  135. </el-form-item>
  136. </el-col>
  137. </el-row>
  138. <el-row>
  139. <el-col :span="6">
  140. <el-form-item label="时间概念强" prop="TimeScore" label-width="130px">
  141. <template>
  142. <el-radio v-model="upData.TimeScore" label="A" style="margin-right: 10px">A</el-radio>
  143. <el-radio v-model="upData.TimeScore" label="B" style="margin-right: 10px">B</el-radio>
  144. <el-radio v-model="upData.TimeScore" label="C" style="margin-right: 10px">C</el-radio>
  145. </template>
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="9">
  149. <el-form-item label="安全意识高" prop="SafetyScore" label-width="260px">
  150. <template>
  151. <el-radio v-model="upData.SafetyScore" label="A" style="margin-right: 10px">A</el-radio>
  152. <el-radio v-model="upData.SafetyScore" label="B" style="margin-right: 10px">B</el-radio>
  153. <el-radio v-model="upData.SafetyScore" label="C" style="margin-right: 10px">C</el-radio>
  154. </template>
  155. </el-form-item>
  156. </el-col>
  157. <el-col :span="9">
  158. <el-form-item label="司机驾龄时间长,提前熟悉路线" prop="DrivingAgeScore" label-width="210px">
  159. <template>
  160. <el-radio v-model="upData.DrivingAgeScore" label="A" style="margin-right: 10px">A</el-radio>
  161. <el-radio v-model="upData.DrivingAgeScore" label="B" style="margin-right: 10px">B</el-radio>
  162. <el-radio v-model="upData.DrivingAgeScore" label="C" style="margin-right: 10px">C</el-radio>
  163. </template>
  164. </el-form-item>
  165. </el-col>
  166. </el-row>
  167. <el-form-item>
  168. <div style="margin-left: 60%;">
  169. <el-button type="primary" @click="editBtn">立即保存</el-button>
  170. <router-link to='/home/CarData'>
  171. <el-button>取消</el-button>
  172. </router-link>
  173. </div>
  174. </el-form-item>
  175. </el-form>
  176. </template>
  177. </div>
  178. </template>
  179. <script>
  180. export default {
  181. data() {
  182. var isnumber = (rule, value, callback) => {
  183. debugger
  184. var reg = /^1[3456789]\d{9}$/;//小数点左边最高16位,小数点右边最多4位
  185. if (reg.test(value)) {
  186. callback();
  187. } else
  188. callback(new Error("请输入正确的手机号"));
  189. };
  190. return {
  191. rules: {
  192. UnitArea: [
  193. { required: true, message: '请输入单位地区', trigger: 'blur' },
  194. { required: true, message: '请输入单位地区', trigger: 'change' },
  195. ],
  196. UnitName: [
  197. { required: true, message: '请输入单位名称', trigger: 'blur' },
  198. ],
  199. Contact: [
  200. { required: true, message: '请输入单位联系人', trigger: 'blur' },
  201. ],
  202. ContactTel: [
  203. { required: true, message: '请输入单位联系人电话', trigger: 'blur' },
  204. { validator: isnumber, message: '请输入正确的手机号', trigger: 'change' }
  205. ],
  206. },
  207. loading: false,
  208. CarDataEdit: {},
  209. currentPage: 1, // 当前页码
  210. pageSize: 15,// 每页的数据条数
  211. input: '',
  212. token: '',
  213. userId: 0,
  214. upData: {
  215. Id: 0,
  216. UnitArea: '',
  217. UnitName: '',
  218. Address: '',
  219. Contact: '',
  220. ContactTel: '',
  221. ContactEmail: '',
  222. ContactFax: '',
  223. CarDes: '',
  224. CarPicPaths: '',
  225. OtherInfo: '',
  226. Score: '5',
  227. QualificationScore: 'A',
  228. CarAgeScore: 'A',
  229. CleanImgScore: 'A',
  230. SmellScore: 'A',
  231. WaterPaperScore: 'A',
  232. HardwareScore: 'A',
  233. TimeScore: 'A',
  234. SafetyScore: 'A',
  235. DrivingAgeScore: 'A',
  236. Remark: ''
  237. },
  238. unitAreas: [],
  239. restaurants: [],
  240. }
  241. },
  242. methods: {
  243. carData() {
  244. var url = "http://localhost:5256/api/Resource/QuerCarData"
  245. var that = this
  246. this.$axios({
  247. method: 'post',
  248. url: url,
  249. headers: {
  250. Authorization: 'Bearer ' + this.token
  251. },
  252. data: {
  253. portType: 1,
  254. }
  255. }).then(function (res) {
  256. console.log(res)
  257. debugger
  258. if (res.data.code == 200) {
  259. debugger
  260. that.tableData = res.data.data;
  261. that.tableData.forEach(function (item, index) {
  262. that.unitAreas.push({
  263. value: item.unitArea,
  264. });
  265. });
  266. }
  267. })
  268. },
  269. handleSelect(item) {
  270. console.log(item);
  271. },
  272. editBtn() {
  273. const that = this;
  274. debugger
  275. this.upData.CreateUserId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  276. this.upData.Remark = this.upData.OtherInfo
  277. that.$refs.upData.validate((valid) => {
  278. if (valid) {
  279. var url = "http://localhost:5256/api/Resource/AddCarData"
  280. that.$axios({
  281. method: 'post',
  282. url: url,
  283. headers: {
  284. Authorization: 'Bearer ' + that.token
  285. },
  286. data: that.upData
  287. }).then(function (res) {
  288. console.log(res)
  289. debugger
  290. if (res.data.code == 200) {
  291. that.$message({
  292. message: '修改成功',
  293. type: 'success'
  294. });
  295. that.loading = true;
  296. setTimeout(() => {
  297. that.$router.push('/home/CarData')
  298. }, 3000);
  299. } else {
  300. that.$message.error('修改失败!');
  301. }
  302. }).catch(function (error) {
  303. that.$message.error("网络错误,请稍后重试");
  304. });
  305. } else {
  306. this.$message.error('请完善信息在保存!');
  307. return false;
  308. }
  309. })
  310. },
  311. querySearch(queryString, cb) {
  312. var arr = this.unitAreas;
  313. for (var i = 0; i < arr.length - 1; i++) {
  314. for (var j = i + 1; j < arr.length; j++) {
  315. if (arr[i].value == arr[j].value) {
  316. arr.splice(j, 1);
  317. //因为数组长度减小1,所以直接 j++ 会漏掉一个元素,所以要 j--
  318. j--;
  319. }
  320. }
  321. }
  322. var restaurants = arr;
  323. var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
  324. // 调用 callback 返回建议列表的数据
  325. cb(results);
  326. },
  327. createFilter(queryString) {
  328. return (restaurant) => {
  329. return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
  330. };
  331. },
  332. editData() {
  333. this.upData.Id = this.CarDataEdit.id;
  334. this.upData.UnitArea = this.CarDataEdit.unitArea;
  335. this.upData.UnitName = this.CarDataEdit.unitName;
  336. this.upData.Address = this.CarDataEdit.address;
  337. this.upData.Contact = this.CarDataEdit.contact;
  338. this.upData.ContactTel = this.CarDataEdit.contactTel;
  339. this.upData.ContactEmail = this.CarDataEdit.contactEmail;
  340. this.upData.ContactFax = this.CarDataEdit.contactFax;
  341. this.upData.CarDes = this.CarDataEdit.carDes;
  342. this.upData.CarPicPaths = this.CarDataEdit.carPicPaths;
  343. this.upData.OtherInfo = this.CarDataEdit.otherInfo;
  344. this.upData.Score = this.CarDataEdit.score;
  345. this.upData.QualificationScore = this.CarDataEdit.qualificationScore;
  346. this.upData.CarAgeScore = this.CarDataEdit.carAgeScore;
  347. this.upData.CleanImgScore = this.CarDataEdit.cleanImgScore;
  348. this.upData.SmellScore = this.CarDataEdit.smellScore;
  349. this.upData.WaterPaperScore = this.CarDataEdit.waterPaperScore;
  350. this.upData.HardwareScore = this.CarDataEdit.hardwareScore;
  351. this.upData.TimeScore = this.CarDataEdit.timeScore;
  352. this.upData.SafetyScore = this.CarDataEdit.safetyScore;
  353. this.upData.DrivingAgeScore = this.CarDataEdit.drivingAgeScore;
  354. this.upData.Remark = this.CarDataEdit.otherInfo;
  355. },
  356. },
  357. mounted() {
  358. debugger
  359. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  360. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  361. debugger
  362. this.CarDataEdit = JSON.parse(localStorage.getItem('CarDataEdit'));
  363. this.carData();
  364. this.editData();
  365. }
  366. }
  367. </script>
  368. <style>
  369. .communal-list {
  370. background-color: #fff;
  371. padding: 10px;
  372. box-shadow: 0 0 5px #0005;
  373. border-radius: 10px;
  374. }
  375. .communal-title {
  376. display: flex;
  377. font-size: 17px;
  378. font-weight: 600;
  379. color: #555;
  380. margin-top: 8px;
  381. margin-bottom: 2px;
  382. justify-content: space-between;
  383. align-items: center;
  384. }
  385. .communal-box {
  386. display: flex;
  387. }
  388. .communal-box>button {
  389. margin-left: 10px;
  390. padding: 8px 20px;
  391. }
  392. </style>