vehicleConfigurationList.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div>
  3. <search-layout :needBox="true">
  4. <template slot="searchItem1">
  5. <span class="label">配置ID</span>
  6. <el-input
  7. v-model="searchParams.configCode"
  8. size="small"
  9. clearable
  10. placeholder="请输入"
  11. maxlength="60"
  12. @keyup.enter.native="doSearch"
  13. >
  14. </el-input>
  15. </template>
  16. <template slot="searchItem2">
  17. <span class="label">配置名称</span>
  18. <el-input
  19. v-model="searchParams.configName"
  20. size="small"
  21. clearable
  22. placeholder="请输入"
  23. maxlength="60"
  24. @keyup.enter.native="doSearch"
  25. >
  26. </el-input>
  27. </template>
  28. <template slot="searchItem3">
  29. <span class="label">配置描述</span>
  30. <el-input
  31. v-model="searchParams.configDescription"
  32. size="small"
  33. clearable
  34. placeholder="请输入"
  35. maxlength="200"
  36. @keyup.enter.native="doSearch"
  37. >
  38. </el-input>
  39. </template>
  40. <template slot="searchItem4">
  41. <span class="label">车辆名称</span>
  42. <el-input
  43. v-model="searchParams.vehicleName"
  44. size="small"
  45. clearable
  46. placeholder="请输入"
  47. maxlength="60"
  48. @keyup.enter.native="doSearch"
  49. >
  50. </el-input>
  51. </template>
  52. <template slot="searchItem5">
  53. <span class="label">车辆描述</span>
  54. <el-input
  55. v-model="searchParams.vehicleDescription"
  56. size="small"
  57. clearable
  58. placeholder="请输入"
  59. maxlength="200"
  60. @keyup.enter.native="doSearch"
  61. >
  62. </el-input>
  63. </template>
  64. <template slot="searchBtn1">
  65. <el-button type="primary" @click="doSearch">查询</el-button>
  66. </template>
  67. <template slot="searchBtn2">
  68. <el-button type="primary" @click="doReset">重置</el-button>
  69. </template>
  70. </search-layout>
  71. <div class="myTabsBox">
  72. <el-tabs v-model="activeName" type="card" @tab-click="pageControl">
  73. <el-tab-pane label="公有" name="1"></el-tab-pane>
  74. <el-tab-pane label="私有" name="2"></el-tab-pane>
  75. </el-tabs>
  76. <el-button
  77. v-bind:class="{ addBtn: true, disabled: activeName === '1' }"
  78. icon="el-icon-circle-plus-outline"
  79. @click="addOne"
  80. type="primary"
  81. :disabled="activeName === '1'"
  82. >新增</el-button
  83. >
  84. </div>
  85. <tableList
  86. ref="table"
  87. style="margin: 0 30px"
  88. :columns="columns"
  89. :getDataWay="getDataWay"
  90. :pagination="pagination"
  91. index
  92. >
  93. <el-table-column label="操作" slot="cgInfos" align="center">
  94. <template v-slot="scope">
  95. <i
  96. v-if="activeName === '2'"
  97. @click="shareRow(scope.row)"
  98. class="el-icon-share elIcon"
  99. title="分享"
  100. ></i>
  101. <i
  102. @click="editRow(scope.row)"
  103. class="el-icon-edit-outline elIcon"
  104. title="编辑"
  105. ></i>
  106. <i
  107. v-if="activeName === '2'"
  108. @click="delOne(scope.row)"
  109. class="el-icon-delete elIcon"
  110. title="删除"
  111. ></i>
  112. </template>
  113. </el-table-column>
  114. </tableList>
  115. </div>
  116. </template>
  117. <script>
  118. import searchLayout from "@/components/grid/searchLayout";
  119. import tableList from "@/components/grid/TableList";
  120. import toolbarTab from "@/components/toolbar/toolbarTab";
  121. export default {
  122. name: "vehicleConfigurationList", // 车辆配置
  123. components: { searchLayout, tableList, toolbarTab },
  124. data() {
  125. return {
  126. searchParams: {
  127. // 搜索参数
  128. configCode: "", // 配置ID
  129. configName: "", // 配置名称
  130. configDescription: "", // 配置描述
  131. vehicleName: "", // 车辆名称
  132. vehicleDescription: "", // 车辆描述
  133. },
  134. activeName: "2",
  135. columns: [
  136. {
  137. label: "配置ID",
  138. prop: "configCode",
  139. },
  140. {
  141. label: "配置名称",
  142. prop: "configName",
  143. },
  144. {
  145. label: "配置描述",
  146. prop: "configDescription",
  147. // showOverflowTooltip: true,
  148. },
  149. {
  150. label: "车辆名称",
  151. prop: "vehicleName",
  152. },
  153. {
  154. label: "车辆描述",
  155. prop: "vehicleDescription",
  156. },
  157. {
  158. label: "传感器配置",
  159. prop: "configSensors",
  160. },
  161. {
  162. label: "操作",
  163. prop: "cgInfos",
  164. template: true,
  165. },
  166. ],
  167. pagination: {
  168. //分页使用
  169. currentPage: 1,
  170. pageSize: 10,
  171. position: "right",
  172. pageSizes: [10, 30, 50, 100, 200],
  173. layout: "sizes, total, prev, pager, next, jumper",
  174. },
  175. getDataWay: {
  176. //加载表格数据
  177. dataType: "url",
  178. type: "post",
  179. // firstRequest: false,
  180. data: this.$api.modelLibrary.getConfigPageList,
  181. param: {
  182. share: "0",
  183. },
  184. },
  185. };
  186. },
  187. methods: {
  188. pageControl(data) {
  189. this.activeName = data.name;
  190. this.doSearch();
  191. },
  192. doSearch() {
  193. let pageMap = {
  194. ...this.searchParams,
  195. share: this.activeName === "1" ? "1" : "0",
  196. };
  197. this.refreshList(pageMap);
  198. },
  199. //刷新table
  200. refreshList(param) {
  201. param
  202. ? this.$refs["table"].loadData(param)
  203. : this.$refs["table"].loadData();
  204. },
  205. doReset() {
  206. this.searchParams = {
  207. configCode: "",
  208. configName: "",
  209. configDescription: "",
  210. vehicleName: "",
  211. vehicleDescription: "",
  212. };
  213. this.doSearch();
  214. },
  215. addOne() {
  216. this.$router.push({ path: "/vehicleConfigurationDetail" });
  217. },
  218. editRow(row) {
  219. this.$router.push({
  220. path: "/vehicleConfigurationDetail",
  221. query: {
  222. id: row.id,
  223. share: row.share,
  224. },
  225. });
  226. },
  227. delOne(row) {
  228. this.$confirm("确认是否删除?", "提示", {
  229. confirmButtonText: "确定",
  230. cancelButtonText: "取消",
  231. type: "warning",
  232. }).then(() => {
  233. this.$axios({
  234. method: "post",
  235. url: this.$api.modelLibrary.delConfigById,
  236. data: {
  237. id: row.id,
  238. },
  239. }).then((res) => {
  240. if (res.code == 200) {
  241. this.$message.success("删除成功");
  242. } else {
  243. this.$message.error(res.message || "删除失败");
  244. }
  245. this.doSearch();
  246. });
  247. });
  248. },
  249. shareRow(row) {
  250. this.$confirm("确认是否分享?", "提示", {
  251. confirmButtonText: "确定",
  252. cancelButtonText: "取消",
  253. type: "warning",
  254. }).then(() => {
  255. this.$axios({
  256. method: "post",
  257. url: this.$api.modelLibrary.shareConfigById,
  258. data: {
  259. id: row.id,
  260. },
  261. }).then((res) => {
  262. if (res.code == 200) {
  263. this.$message.success("分享成功");
  264. } else {
  265. this.$message.error(res.message || "分享失败");
  266. }
  267. this.doSearch();
  268. });
  269. });
  270. },
  271. },
  272. created() {},
  273. };
  274. </script>
  275. <style scoped lang="less">
  276. </style>