scenePacketDistributionDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div>
  3. <div class="infoBox">
  4. <div class="info">
  5. <span>账户名:</span>
  6. <b>{{ info.userName || "" }}</b>
  7. </div>
  8. <div class="info">
  9. <span>所属公司:</span>
  10. <b>{{ info.company || "" }}</b>
  11. </div>
  12. </div>
  13. <!-- <search-layout :needBox="true">
  14. <template slot="searchItem1">
  15. <span class="label">场景包名称</span>
  16. <el-input
  17. v-model="searchParams.packageName"
  18. size="small"
  19. clearable
  20. placeholder="请输入"
  21. maxlength="60"
  22. @keyup.enter.native="doSearch"
  23. >
  24. </el-input>
  25. </template>
  26. <template slot="searchBtn1">
  27. <el-button type="primary" @click="doSearch">查询</el-button>
  28. </template>
  29. <template slot="searchBtn2">
  30. <el-button type="primary" @click="doReset">重置</el-button>
  31. </template>
  32. </search-layout> -->
  33. <div class="flexBox summaryBox">
  34. <div class="left flexBox">
  35. <div class="num">
  36. 场景总数:
  37. {{ total }}
  38. </div>
  39. <div class="numA">交通事故场景: {{ jtSceneNames }}</div>
  40. <div class="numA">自然驾驶场景: {{ zrSceneNames }}</div>
  41. <div class="numA">标准法规场景: {{ bzSceneNames }}</div>
  42. <div class="num">泛化场景: {{ fhSceneNames }}</div>
  43. </div>
  44. <div class="right">
  45. <el-button type="primary" @click="showNums">汇总</el-button>
  46. </div>
  47. </div>
  48. <div class="searchBox flexBox">
  49. <div class="isSelected">
  50. <el-checkbox v-model="selected" @change="selectedShow"
  51. >已选择</el-checkbox
  52. >
  53. </div>
  54. <div class="inputPanel">
  55. <el-input
  56. v-model="searchParams.packageName"
  57. size="small"
  58. clearable
  59. placeholder="请输入场景包名称"
  60. maxlength="60"
  61. class="input-with-select"
  62. >
  63. <el-button
  64. slot="append"
  65. icon="el-icon-search"
  66. @click="doSearch"
  67. ></el-button>
  68. </el-input>
  69. </div>
  70. </div>
  71. <tableList
  72. ref="table"
  73. style="margin: 0 30px"
  74. :columns="columns"
  75. :getDataWay="getDataWay"
  76. :pagination="pagination"
  77. :checkedData="checkedArr"
  78. :needLoadedCallBack="true"
  79. :loadedCallBack="loadedCallBack"
  80. :needSelectedCallBack="true"
  81. :selectedCallBack="selectedCallBack"
  82. :selectedAllCallBack="selectedAllCallBack"
  83. index
  84. selection
  85. >
  86. </tableList>
  87. <div class="btns">
  88. <el-button type="primary" @click="save">确定</el-button>
  89. <el-button type="primary" plain @click="cancel">取消</el-button>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import searchLayout from "@/components/grid/searchLayout";
  95. import tableList from "@/components/grid/TableList";
  96. export default {
  97. name: "scenePacketDistributionDetail", // 场景包分配详情
  98. components: { searchLayout, tableList },
  99. data() {
  100. return {
  101. searchParams: {
  102. //搜索参数
  103. packageName: "", // 场景包名称
  104. },
  105. columns: [
  106. {
  107. label: "场景包名称",
  108. prop: "packageName",
  109. },
  110. {
  111. label: "描述",
  112. prop: "sceneDescribe",
  113. showOverflowTooltip: true,
  114. },
  115. {
  116. label: "自然驾驶场景",
  117. prop: "zrCount",
  118. },
  119. {
  120. label: "交通事故场景",
  121. prop: "jtCount",
  122. },
  123. {
  124. label: "标准法规场景",
  125. prop: "bzCount",
  126. },
  127. {
  128. label: "泛化场景",
  129. prop: "fhCount",
  130. },
  131. ],
  132. pagination: {
  133. //分页使用
  134. currentPage: 1,
  135. pageSize: 10,
  136. position: "right",
  137. pageSizes: [10, 30, 50, 100, 200],
  138. layout: "sizes, total, prev, pager, next, jumper",
  139. },
  140. getDataWay: {
  141. //加载表格数据
  142. dataType: "url",
  143. type: "post",
  144. // firstRequest: false,
  145. data: this.$api.systemManagement.querySystemScenePackageList,
  146. param: {},
  147. },
  148. selected: false, // 是否选中展示已选择项
  149. checkedArr: [], // 列表当前页已选
  150. checkedNames: [], // 列表所有已选
  151. total: 0,
  152. jtSceneNames: 0,
  153. zrSceneNames: 0,
  154. bzSceneNames: 0,
  155. fhSceneNames: 0,
  156. info: {},
  157. };
  158. },
  159. methods: {
  160. doSearch() {
  161. let data = {
  162. ...this.searchParams,
  163. };
  164. if (this.selected) {
  165. data.packageNames = this.checkedNames;
  166. } else {
  167. data.packageNames = null;
  168. }
  169. this.refreshList(data);
  170. },
  171. //刷新table
  172. refreshList(param) {
  173. param
  174. ? this.$refs["table"].loadData(param)
  175. : this.$refs["table"].loadData();
  176. },
  177. doReset() {
  178. this.searchParams = {
  179. packageName: "",
  180. };
  181. this.doSearch();
  182. },
  183. // 数据加载后的回调
  184. loadedCallBack() {
  185. this.checkedArr = [];
  186. this.$refs.table.tableData.forEach((i) => {
  187. if (this.checkedNames.includes(i.packageName)) {
  188. // 显示已选中的项
  189. this.$refs.table.$refs.ListTable.toggleRowSelection(
  190. i,
  191. true
  192. );
  193. this.checkedArr.push(i);
  194. }
  195. });
  196. },
  197. // 用户勾选完执行函数后的回调
  198. selectedCallBack(row, type) {
  199. if (type === 1) {
  200. if (!this.checkedNames.includes(row.packageName)) {
  201. this.checkedNames.push(row.packageName);
  202. }
  203. } else {
  204. let index = this.checkedNames.indexOf(row.packageName);
  205. if (index > -1) {
  206. this.checkedNames.splice(index, 1);
  207. }
  208. }
  209. },
  210. // 用户勾选全选执行函数后的回调
  211. selectedAllCallBack(selection, type) {
  212. if (type === 1) {
  213. selection.forEach((i) => {
  214. if (!this.checkedNames.includes(i.packageName)) {
  215. this.checkedNames.push(i.packageName);
  216. }
  217. });
  218. } else {
  219. this.$refs.table.tableData.forEach((i) => {
  220. let index = this.checkedNames.indexOf(i.packageName);
  221. if (index > -1) {
  222. this.checkedNames.splice(index, 1);
  223. }
  224. });
  225. }
  226. },
  227. selectedShow() {
  228. this.doSearch();
  229. },
  230. showNums() {
  231. if (this.checkedNames.length === 0) {
  232. this.$message.error("请先选择场景包");
  233. this.zrSceneNames = 0;
  234. this.bzSceneNames = 0;
  235. this.jtSceneNames = 0;
  236. this.fhSceneNames = 0;
  237. this.total = 0;
  238. return;
  239. }
  240. this.zrSceneNames = 0;
  241. this.bzSceneNames = 0;
  242. this.jtSceneNames = 0;
  243. this.fhSceneNames = 0;
  244. this.total = 0;
  245. this.$axios({
  246. method: "post",
  247. url: this.$api.systemManagement.querySystemScenePackageListByTJ,
  248. data: { packageNames: this.checkedNames },
  249. }).then((res) => {
  250. if (res.code == 200 && res.info) {
  251. res.info.forEach((i) => {
  252. switch (i.scene_type) {
  253. case "1":
  254. this.zrSceneNames = i.aaa;
  255. break;
  256. case "2":
  257. this.bzSceneNames = i.aaa;
  258. break;
  259. case "3":
  260. this.jtSceneNames = i.aaa;
  261. break;
  262. case "4":
  263. this.fhSceneNames = i.aaa;
  264. break;
  265. default:
  266. break;
  267. }
  268. });
  269. this.total =
  270. this.zrSceneNames +
  271. this.bzSceneNames +
  272. this.jtSceneNames +
  273. this.fhSceneNames;
  274. } else {
  275. this.$message.error(res.message || "获取信息失败");
  276. }
  277. });
  278. },
  279. save() {
  280. if (this.checkedNames.length === 0) {
  281. this.$message.error("请先选择场景包");
  282. return;
  283. }
  284. let data = Object.assign({}, this.info, {
  285. packageNames: this.checkedNames,
  286. });
  287. this.$axios({
  288. method: "post",
  289. url: this.$api.systemManagement.savePackageByUserId,
  290. data,
  291. }).then((res) => {
  292. if (res.code == 200) {
  293. this.$message.success("保存成功");
  294. this.cancel();
  295. } else {
  296. this.$message.error(res.message || "保存失败");
  297. }
  298. });
  299. },
  300. cancel() {
  301. this.$router.replace({ path: "/scenePacketDistributionList" });
  302. },
  303. },
  304. mounted() {
  305. if (this.$route.query.userName) {
  306. this.$axios({
  307. method: "post",
  308. url: this.$api.systemManagement.queryPackageByUserId,
  309. data: { userName: this.$route.query.userName },
  310. }).then((res) => {
  311. if (res.code == 200 && res.info) {
  312. this.info = res.info;
  313. this.checkedNames = res.info.packageNames || [];
  314. this.loadedCallBack();
  315. this.showNums();
  316. } else {
  317. this.$message.error(res.message || "获取信息失败");
  318. }
  319. });
  320. }
  321. },
  322. };
  323. </script>
  324. <style lang='less' scoped>
  325. .infoBox {
  326. display: flex;
  327. padding: 24px 12px 0;
  328. .info {
  329. display: flex;
  330. flex: 1;
  331. margin-right: 20px;
  332. word-break: break-all;
  333. span {
  334. display: block;
  335. width: 70px;
  336. padding-right: 10px;
  337. text-align: right;
  338. }
  339. b {
  340. flex: 1;
  341. font-weight: normal;
  342. }
  343. }
  344. }
  345. .summaryBox {
  346. padding: 30px 40px 0;
  347. color: @themeColor;
  348. font-size: 18px;
  349. font-weight: bold;
  350. .left {
  351. margin-right: 30px;
  352. line-height: 32px;
  353. > div {
  354. margin-right: 30px;
  355. }
  356. .num {
  357. min-width: 120px;
  358. }
  359. .numA {
  360. min-width: 156px;
  361. }
  362. }
  363. }
  364. .searchBox {
  365. align-items: center;
  366. justify-content: space-between;
  367. padding: 30px 40px 10px 40px;
  368. }
  369. .inputPanel {
  370. .el-input {
  371. width: 300px;
  372. }
  373. /deep/ .el-input-group__append {
  374. background-color: #fff;
  375. border-color: #e5e5e5;
  376. padding: 0;
  377. overflow: hidden;
  378. }
  379. /deep/ .el-input-group__append button.el-button,
  380. /deep/ .el-input-group__append div.el-select .el-input__inner,
  381. /deep/ .el-input-group__append div.el-select:hover .el-input__inner,
  382. /deep/ .el-input-group__prepend button.el-button,
  383. /deep/ .el-input-group__prepend div.el-select .el-input__inner,
  384. /deep/ .el-input-group__prepend div.el-select:hover .el-input__inner {
  385. border-color: transparent;
  386. background-color: transparent;
  387. color: inherit;
  388. border-top: 0;
  389. border-bottom: 0;
  390. }
  391. }
  392. .btns {
  393. padding-top: 30px;
  394. text-align: center;
  395. }
  396. </style>