taker_car.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :operation="operation()"
  6. :optionsEvensGroup="optionsEvensGroup"
  7. :exportList="exportList"
  8. :columnParsing="columnParsing"
  9. :tableAttributes="tableAttributes"
  10. :tableEvents="tableEvents"
  11. :operationColumnWidth="200"
  12. >
  13. <!-- 弹窗 -->
  14. <el-dialog
  15. title="提货车辆档案"
  16. :visible.sync="dialogForm"
  17. width="40%"
  18. :show-close="false"
  19. :close-on-click-modal="false"
  20. >
  21. <el-form ref="addForm" :rules="rules" :model="addForm" label-width="120px" class="demo-ruleForm">
  22. <el-form-item label="经销商名称" prop="customerId">
  23. <el-select v-model="addForm.customerId" placeholder="请选择经销商名称">
  24. <el-option v-for="item in dealerList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-row>
  28. <el-col :span="12">
  29. <el-form-item label="车牌号" prop="carBrand">
  30. <el-input v-model="addForm.carBrand"></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="12">
  34. <el-form-item label="联系电话" prop="mobile">
  35. <el-input v-model="addForm.mobile"></el-input>
  36. </el-form-item>
  37. </el-col>
  38. </el-row>
  39. <el-row>
  40. <el-col :span="12">
  41. <el-form-item label="车型" prop="carType">
  42. <el-input v-model="addForm.carType"></el-input>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="12">
  46. <el-form-item label="体积" prop="volume">
  47. <el-input v-model="addForm.volume">
  48. <i class="el-input__icon" slot="suffix">m³ </i>
  49. </el-input>
  50. </el-form-item>
  51. </el-col>
  52. </el-row>
  53. </el-form>
  54. <div slot="footer" class="dialog-footer">
  55. <el-button @click="cancelFn">取 消</el-button>
  56. <el-button type="primary" @click="addDataListFn">确 定</el-button>
  57. </div>
  58. </el-dialog>
  59. </template-page>
  60. </template>
  61. <script>
  62. import TemplatePage from '@/components/template/template-page-1.vue'
  63. import {
  64. getCarList,
  65. addDataListApi,
  66. delCarFn,
  67. editDataListApi,
  68. v2TakerCarRecordList,
  69. v2TakerCarRecordListExport
  70. } from '@/api/basic_data/taker'
  71. import { getDealerList } from '@/api/basic_data/dealer'
  72. import { downloadFiles } from '@/utils/util'
  73. export default {
  74. components: {
  75. TemplatePage
  76. },
  77. data() {
  78. return {
  79. // 事件组合
  80. optionsEvensGroup: [
  81. [
  82. [
  83. {
  84. name: '新增',
  85. click: () => {
  86. this.addDataList()
  87. },
  88. isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  89. }
  90. ]
  91. ],
  92. [
  93. [
  94. {
  95. name: '批量删除',
  96. click: async () => {
  97. if (this.recordSelected.length === 0) {
  98. this.$message.error('请选择需要删除的数据')
  99. return
  100. }
  101. this.delFn()
  102. },
  103. isRole: this.$checkBtnRole('del', this.$route.meta.roles)
  104. }
  105. ]
  106. ]
  107. ],
  108. // 表格属性
  109. tableAttributes: {
  110. // 启用勾选列
  111. selectColumn: true
  112. },
  113. // 表格事件
  114. tableEvents: {
  115. 'selection-change': this.selectionChange
  116. },
  117. recordSelected: [],
  118. listLoading: false, // 列表加载loading
  119. currentPage: 1, // 当前页码
  120. pageSize: 10, // 每页数量
  121. listTotal: 0, // 列表总数
  122. addForm: {
  123. customerId: '',
  124. mobile: '',
  125. carType: '',
  126. volume: '',
  127. carBrand: ''
  128. },
  129. rules: {
  130. customerId: [{ required: true, message: '请选择活动区域', trigger: 'change' }],
  131. mobile: [
  132. {
  133. required: true,
  134. message: '请输入联系电话',
  135. trigger: 'blur'
  136. },
  137. {
  138. pattern: /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/,
  139. message: '联系电话格式不正确',
  140. trigger: 'blur'
  141. }
  142. ],
  143. // carType: [{ required: true, message: "车型不能为空", trigger: "blur" }],
  144. // volume: [{ required: true, message: "体积不能为空", trigger: "blur" }],
  145. carBrand: [{ required: true, message: '车牌号不能为空', trigger: 'blur' }]
  146. },
  147. dialogForm: false,
  148. isCollapse: true,
  149. dataList: [],
  150. searchForm: {
  151. customerName: '',
  152. carBrand: ''
  153. },
  154. dealerList: [],
  155. ids: []
  156. }
  157. },
  158. computed: {
  159. exParams() {
  160. return {
  161. carBrand: this.searchForm.carBrand,
  162. customerName: this.searchForm.customerName
  163. }
  164. }
  165. },
  166. async created() {
  167. this.getDataList()
  168. this.getDealerDataList({ pageNum: 1, pageSize: 10 })
  169. },
  170. methods: {
  171. // 列表请求函数
  172. getList: v2TakerCarRecordList,
  173. // 列表导出函数
  174. exportList: v2TakerCarRecordListExport,
  175. // 表格列解析渲染数据更改
  176. columnParsing(item, defaultData) {
  177. return defaultData
  178. },
  179. // 监听勾选变化
  180. selectionChange(data) {
  181. this.recordSelected = data
  182. },
  183. operation() {
  184. return (h, { row, index, column }) => {
  185. return (
  186. <div class="operation-btns">
  187. {this.$checkBtnRole('del', this.$route.meta.roles) ? (
  188. <el-popconfirm
  189. onConfirm={async () => {
  190. this.delFn(row.id)
  191. }}
  192. title="是否确定需要删除该项内容?"
  193. >
  194. <el-button slot="reference" size="mini" type="text">
  195. 删除
  196. </el-button>
  197. </el-popconfirm>
  198. ) : (
  199. ''
  200. )}
  201. {this.$checkBtnRole('edit', this.$route.meta.roles) ? (
  202. <el-button
  203. size="mini"
  204. type="text"
  205. onClick={async () => {
  206. this.editFn(row)
  207. }}
  208. >
  209. 编辑
  210. </el-button>
  211. ) : (
  212. ''
  213. )}
  214. </div>
  215. )
  216. }
  217. },
  218. // 筛选部分数据或者单个
  219. hanleSelect(selection) {
  220. // this.ids = selection.map((k) => {
  221. // return k.id;
  222. // });
  223. // console.log(selection);
  224. this.ids = selection.map(v => v.id)
  225. // console.log(this.ids);
  226. },
  227. // //导出
  228. // exportFn() {
  229. // let screenData = {
  230. // customerName: this.searchForm.customerName,
  231. // carBrand: this.searchForm.carBrand,
  232. // };
  233. // downloadFiles("/take-car-record/export", screenData);
  234. // },
  235. //取消
  236. async cancelFn() {
  237. if (this.addForm.id) {
  238. this.addForm = {
  239. customerId: '',
  240. mobile: '',
  241. carType: '',
  242. volume: '',
  243. carBrand: ''
  244. }
  245. } else {
  246. await this.$refs.addForm.resetFields()
  247. }
  248. this.dialogForm = false
  249. },
  250. //编辑
  251. editFn(data) {
  252. this.addForm = data
  253. this.dialogForm = true
  254. },
  255. //重置
  256. clearFn() {
  257. console.log(this.$refs.searchForm)
  258. this.$refs.searchForm.resetFields()
  259. },
  260. //搜索
  261. async searchFn() {
  262. this.currentPage = 1
  263. await this.getDataList()
  264. },
  265. //删除
  266. async delFn(ids) {
  267. if (ids) {
  268. let arr = []
  269. arr.push(ids)
  270. let res = arr.toString()
  271. await delCarFn({ ids: res })
  272. } else {
  273. let res = this.recordSelected.map(v => v.id).toString()
  274. await delCarFn({ ids: res })
  275. }
  276. this.$message.success('删除成功')
  277. this.ids = []
  278. // this.getDataList()
  279. this.$refs.pageRef.refreshList()
  280. },
  281. //获取经销商数据
  282. async getDealerDataList(data) {
  283. const res = await getDealerList(data)
  284. this.dealerList = res.data.records
  285. },
  286. //新增
  287. async addDataList() {
  288. this.addForm = {
  289. customerId: '',
  290. mobile: '',
  291. carType: '',
  292. volume: '',
  293. carBrand: ''
  294. }
  295. this.dialogForm = true
  296. },
  297. async addDataListFn() {
  298. await this.$refs.addForm.validate()
  299. const res = this.dealerList.filter(v => v.id === this.addForm.customerId)[0]
  300. if (this.addForm.id) {
  301. await editDataListApi({ ...this.addForm })
  302. this.$message.success('编辑成功')
  303. } else {
  304. await addDataListApi({ ...this.addForm, orgNumber: res.useOrgNumber })
  305. this.$message.success('添加成功')
  306. }
  307. // console.log(res);
  308. //
  309. // this.addForm = {
  310. // customerId: "",
  311. // mobile: "",
  312. // carType: "",
  313. // volume: "",
  314. // carBrand: "",
  315. // };
  316. await this.$refs.addForm.resetFields()
  317. // this.getDataList()
  318. this.$refs.pageRef.refreshList()
  319. this.dialogForm = false
  320. },
  321. //获取列表数据
  322. async getDataList() {
  323. let params = {
  324. carBrand: this.searchForm.carBrand,
  325. customerName: this.searchForm.customerName,
  326. pageSize: this.pageSize,
  327. pageNum: this.currentPage
  328. }
  329. const res = await getCarList(params)
  330. this.dataList = res.data.records
  331. this.listTotal = res.data.total
  332. },
  333. // 更改每页数量
  334. handleSizeChange(val) {
  335. this.pageSize = val
  336. this.currentPage = 1
  337. this.getDataList()
  338. },
  339. // 更改当前页
  340. handleCurrentChange(val) {
  341. this.currentPage = val
  342. this.getDataList()
  343. }
  344. }
  345. }
  346. </script>
  347. <style lang="scss" scoped>
  348. .add-right {
  349. margin-right: 10px;
  350. }
  351. // ::v-deep .el-popover__reference {
  352. // margin-left: 10px;
  353. // }
  354. ::v-deep .el-date-editor {
  355. width: 100%;
  356. }
  357. ::v-deep .el-select {
  358. width: 100%;
  359. }
  360. ::v-deep .el-col-9 .el-button {
  361. padding: 5px;
  362. }
  363. ::v-deep .el-dialog__header {
  364. background-color: #dddddd;
  365. }
  366. </style>