autoRunProjectDetail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <div>
  3. <el-form ref="form" :model="form" :rules="rules" label-width="135px" class="flexBox">
  4. <div class="formItemBox">
  5. <el-form-item label="项目名称:" prop="projectName">
  6. <el-input placeholder="请输入" maxlength="120" v-autoTrim="{ obj: form, key: 'projectName' }"
  7. v-model="form.projectName">
  8. </el-input>
  9. </el-form-item>
  10. <el-form-item label="项目描述:" prop="projectDescribe">
  11. <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 4 }" placeholder="请输入" maxlength="300"
  12. v-autoTrim="{ obj: form, key: 'projectDescribe' }" v-model="form.projectDescribe">
  13. </el-input>
  14. </el-form-item>
  15. <!-- <el-form-item label="算法来源:" prop="algorithmType">
  16. <el-radio
  17. v-model="form.algorithmType"
  18. label="1"
  19. @change="typeChange"
  20. >私有导入</el-radio
  21. >
  22. <el-radio
  23. v-model="form.algorithmType"
  24. label="3"
  25. @change="typeChange"
  26. >算法平台</el-radio
  27. >
  28. </el-form-item> -->
  29. <el-form-item label="选择算法:" prop="algorithmArrayS">
  30. <el-cascader ref="cascaderA" v-model="form.algorithmArrayS" :options="algorithmList" :props="props"
  31. @change="algorithmSelChange"></el-cascader>
  32. <!-- <el-select v-model="form.algorithm">
  33. <el-option
  34. v-for="item in algorithmList"
  35. :label="item.name"
  36. :value="item.id"
  37. :key="item.id"
  38. :title="item.description"
  39. ></el-option>
  40. </el-select> -->
  41. </el-form-item>
  42. <el-form-item label="选择车辆:" prop="vehicleArrayS">
  43. <el-cascader ref="cascaderB" v-model="form.vehicleArrayS" :options="vehicleList" :props="props"
  44. @change="vehicleSelChange"></el-cascader>
  45. <!-- <el-select
  46. v-model="form.vehicle"
  47. @change="vehicleSelChange"
  48. >
  49. <el-option
  50. v-for="item in vehicleList"
  51. :label="item.name"
  52. :value="item.id"
  53. :key="item.id"
  54. :title="item.description"
  55. ></el-option>
  56. </el-select> -->
  57. </el-form-item>
  58. <el-form-item label="选择场景:" prop="sceneArrayS">
  59. <el-cascader ref="cascaderC" v-model="form.sceneArrayS" :options="sceneList" :props="props"
  60. @change="sceneSelChange"></el-cascader>
  61. <!-- <el-select v-model="form.scene" @change="sceneSelChange">
  62. <el-option
  63. v-for="item in sceneList"
  64. :label="item.name"
  65. :value="item.id"
  66. :key="item.id"
  67. ></el-option>
  68. </el-select> -->
  69. </el-form-item>
  70. <el-form-item label="并行度:" prop="parallelism">
  71. <el-input :disabled="runDisabled" placeholder="请输入" maxlength="10"
  72. v-autoTrim="{ obj: form, key: 'parallelism' }" v-model="form.parallelism">
  73. </el-input>
  74. </el-form-item>
  75. <el-form-item label="最大仿真时间(s):" prop="maxSimulationTime">
  76. <el-input placeholder="请输入" maxlength="10" v-autoTrim="{ obj: form, key: 'maxSimulationTime' }"
  77. v-model="form.maxSimulationTime">
  78. </el-input>
  79. </el-form-item>
  80. <el-form-item label="运行周期:" prop="operationCycle">
  81. <el-input placeholder="请输入" maxlength="60" v-autoTrim="{ obj: form, key: 'operationCycle' }"
  82. v-model="form.operationCycle">
  83. </el-input>
  84. </el-form-item>
  85. <el-form-item label="是否选择GPU:" prop="isChoiceGpu">
  86. <el-radio v-model="form.isChoiceGpu" label="0">是</el-radio>
  87. <el-radio v-model="form.isChoiceGpu" label="1">否</el-radio>
  88. </el-form-item>
  89. </div>
  90. <div class="tipBox">
  91. <div class="tip tipA">
  92. <!-- (传感器1:根据车辆自动带出;传感器2:根据车辆自动带出) -->
  93. <span v-for="item in sensors" :key="item" v-bind:class="{
  94. iconA: item === 'camera',
  95. iconB: item === 'ogt',
  96. iconC: item === 'lidar',
  97. iconE: item === 'gps',
  98. }"></span>
  99. </div>
  100. <div class="tip">(场景数量:{{ sceneCount }})</div>
  101. <!-- <div class="tip flexBox">
  102. <div>(下次运行时间:XX时XX分XX秒)</div>
  103. <div class="tipBtnBox">
  104. <el-button type="primary">规则查看</el-button>
  105. </div>
  106. </div> -->
  107. <div class="tip">(最多可用资源:{{ maxCount }})</div>
  108. <div class="tip">(最小是5,最大是10000)</div>
  109. </div>
  110. </el-form>
  111. <div class="ruleTip">
  112. <el-collapse v-model="activeNames">
  113. <el-collapse-item title="运行周期规则查看" name="1">
  114. <!-- <div class="collapseInfo">运行周期规则查看</div> -->
  115. <div class="collapseInfo">
  116. <span>参考网址:</span>
  117. <a href="https://cron.qqe2.com" target="_blank">https://cron.qqe2.com</a>
  118. </div>
  119. </el-collapse-item>
  120. </el-collapse>
  121. </div>
  122. <div class="btns">
  123. <el-button type="primary" @click="save(false)">保存</el-button>
  124. <el-button type="primary" @click="save(true)" v-if="this.$route.query.id">另存为</el-button>
  125. <el-button type="primary" @click="save(false, true)" :disabled="runDisabled">提交</el-button>
  126. <el-button type="primary" plain @click="cancel">取消</el-button>
  127. </div>
  128. </div>
  129. </template>
  130. <script>
  131. //import from '';
  132. let maxCount = 0; // 用于校验
  133. let validateNum = (rule, value, callback) => {
  134. !/^(\d+)$/.test(value) && callback(new Error(rule.message));
  135. if (+value <= 0 || +value > +maxCount) callback(new Error(rule.message));
  136. callback();
  137. };
  138. let validateNumA = (rule, value, callback) => {
  139. !/^(\d+)$/.test(value) && callback(new Error(rule.message));
  140. if (+value < 5 || +value > 10000) callback(new Error(rule.message));
  141. callback();
  142. };
  143. let validateNumB = (rule, value, callback) => {
  144. !/^(\d+)$/.test(value) && callback(new Error(rule.message));
  145. if (+value <= 0) callback(new Error(rule.message));
  146. callback();
  147. };
  148. export default {
  149. name: "autoRunProjectDetail", // 自动化测试详情
  150. components: {},
  151. data() {
  152. return {
  153. form: {
  154. id: "",
  155. projectName: "", // 项目名称
  156. projectDescribe: "", // 项目描述
  157. algorithmType: "2", // 算法来源
  158. algorithm: "", // 选择算法
  159. algorithmArrayS: "", // 选择算法
  160. vehicle: "", // 选择车辆
  161. vehicleArrayS: "", // 选择车辆
  162. scene: "", // 选择场景
  163. sceneArrayS: "", // 选择场景
  164. parallelism: "", // 并行度
  165. maxSimulationTime: "", // 最大仿真时间
  166. isChoiceGpu: "0", // 是否选择GPU
  167. nowRunState: "10", // 运行状态
  168. operationCycle: "", // 运行周期
  169. },
  170. algorithmList: [], // 算法对应列表
  171. vehicleList: [], // 车辆对应列表
  172. sceneList: [], // 场景对应列表
  173. maxCount: 0, // 最多可用资源
  174. sceneCount: 0, // 场景数量
  175. rules: {
  176. projectName: [
  177. { required: true, message: "请输入", trigger: "blur" },
  178. ],
  179. projectDescribe: [
  180. { required: true, message: "请输入", trigger: "blur" },
  181. ],
  182. // algorithmType: [
  183. // { required: true, message: "请选择", trigger: "change" },
  184. // ],
  185. algorithmArrayS: [
  186. { required: true, message: "请选择", trigger: "change" },
  187. ],
  188. vehicleArrayS: [
  189. { required: true, message: "请选择", trigger: "change" },
  190. ],
  191. sceneArrayS: [
  192. { required: true, message: "请选择", trigger: "change" },
  193. ],
  194. parallelism: [
  195. { required: true, message: "请输入", trigger: "blur" },
  196. ],
  197. maxSimulationTime: [
  198. { required: true, message: "请输入", trigger: "blur" },
  199. {
  200. validator: validateNumA,
  201. message: "请输入不小于5且不大于10000的正整数",
  202. trigger: ["blur"],
  203. },
  204. ],
  205. isChoiceGpu: [
  206. { required: true, message: "请选择", trigger: "change" },
  207. ],
  208. operationCycle: [
  209. { required: true, message: "请输入", trigger: "blur" },
  210. ],
  211. },
  212. sensors: [], // 选中车辆后对应的传感器数组
  213. activeNames: [""],
  214. runDisabled: false, // 若最多可用资源为0,则不可点击"提交"
  215. props: {
  216. multiple: false,
  217. label: "name",
  218. value: "code",
  219. },
  220. };
  221. },
  222. computed: {},
  223. methods: {
  224. async getLists(dropDownType = "") {
  225. await this.$axios({
  226. method: "post",
  227. url: this.$api.workManagement.selectDropDownByTypeNew,
  228. data: {
  229. dropDownType,
  230. algorithmType: this.form.algorithmType,
  231. },
  232. }).then((res) => {
  233. if (res.code == 200 && res.info) {
  234. res.info.forEach((item) => {
  235. if (item.type === "1") {
  236. // item.dropDownList.forEach((i) => {
  237. // if (i.share === "1") i.name = i.name + "(公有)";
  238. // });
  239. this.algorithmList = item.dropDownList;
  240. } else if (item.type === "2") {
  241. // item.dropDownList.forEach((i) => {
  242. // if (i.share === "1") i.name = i.name + "(公有)";
  243. // });
  244. this.vehicleList = item.dropDownList;
  245. } else if (item.type === "3") {
  246. // item.dropDownList.forEach((i) => {
  247. // if (i.share === "1") i.name = i.name + "(公有)";
  248. // });
  249. this.sceneList = item.dropDownList;
  250. }
  251. // 空表示第一次进,有值表示在切换算法来源,需要清空选择算法的值
  252. if (dropDownType) {
  253. this.form.algorithm = "";
  254. this.form.algorithmArrayS = [];
  255. this.$nextTick(() => {
  256. // this.$refs.form.clearValidate("algorithm");
  257. this.$refs.form.clearValidate("algorithmArrayS");
  258. });
  259. }
  260. });
  261. } else {
  262. this.$message.error(res.message || "获取信息失败");
  263. }
  264. });
  265. },
  266. typeChange() {
  267. this.getLists("1");
  268. },
  269. async getMaxSimulationTime() {
  270. await this.$axios({
  271. method: "post",
  272. url: this.$api.workManagement.selectMaxParallelism,
  273. data: {},
  274. }).then((res) => {
  275. // res.info = 10;
  276. if (res.code == 200 && res.info && res.info != 0) {
  277. this.maxCount = maxCount = res.info;
  278. if (res.info == -1) {
  279. this.rules.parallelism.push({
  280. validator: validateNumB,
  281. message: "请输入正整数",
  282. trigger: ["blur"],
  283. });
  284. } else {
  285. this.rules.parallelism.push({
  286. validator: validateNum,
  287. message: "请输入不大于最多可用资源的正整数",
  288. trigger: ["blur"],
  289. });
  290. }
  291. } else if (res.code == 200 && res.info == 0) {
  292. this.maxCount = maxCount = 0;
  293. this.runDisabled = true;
  294. this.form.parallelism = 0;
  295. } else {
  296. this.$message.error(res.message || "获取信息失败");
  297. }
  298. });
  299. },
  300. algorithmSelChange(v) {
  301. let item = this.$refs.cascaderA.getCheckedNodes(true)[0].data.vo;
  302. this.form.algorithm = item.id;
  303. },
  304. vehicleSelChange(v) {
  305. let item = this.$refs.cascaderB.getCheckedNodes(true)[0].data.vo;
  306. this.form.vehicle = item.id;
  307. let sensor = item.sensor;
  308. if (!sensor) {
  309. this.sensors = [];
  310. } else {
  311. this.sensors = sensor.split(",");
  312. }
  313. },
  314. sceneSelChange(v) {
  315. let item = this.$refs.cascaderC.getCheckedNodes(true)[0].data.vo;
  316. this.form.scene = item.id;
  317. this.sceneCount = item.sceneNum
  318. },
  319. save(isAdd = false, needChange = false) {
  320. // isAdd是否强制新增,needChange是否需要改变状态
  321. this.$refs.form.validate((valid) => {
  322. if (valid) {
  323. if (isAdd) {
  324. // 另存为
  325. this.form.id = "";
  326. }
  327. this.form.nowRunState = "10";
  328. this.$axios({
  329. method: "post",
  330. url: this.$api.workManagement
  331. .addOrUpdateAutomaticProject,
  332. data: {
  333. ...this.form,
  334. },
  335. }).then((res) => {
  336. if (res.code == 200) {
  337. this.$message.success("保存成功");
  338. if (needChange) {
  339. this.form.id = res.info;
  340. this.stateChange();
  341. } else {
  342. this.cancel();
  343. }
  344. } else {
  345. this.$message.error(res.message || "保存失败");
  346. }
  347. });
  348. }
  349. });
  350. },
  351. cancel() {
  352. this.$router.replace({ path: "/autoRunProjectList" });
  353. },
  354. stateChange() {
  355. this.$axios({
  356. method: "post",
  357. url: this.$api.workManagement.updateAutomaticRunState,
  358. data: {
  359. id: this.form.id,
  360. automaticRunState: "0",
  361. },
  362. }).then((res) => {
  363. if (res.code == 200) {
  364. this.$message.success("提交成功");
  365. this.cancel();
  366. } else {
  367. this.$message.error(res.message || "提交失败");
  368. }
  369. });
  370. },
  371. },
  372. mounted() {
  373. if (this.$route.query.id) {
  374. let id = "";
  375. this.form.id = id = this.$route.query.id;
  376. if (id) {
  377. this.$axios({
  378. method: "post",
  379. url: this.$api.workManagement.selectAutomaticProjectById,
  380. data: {
  381. id,
  382. },
  383. }).then(async (res) => {
  384. if (res.code == 200 && res.info) {
  385. this.form = res.info;
  386. this.form.algorithmType = "2";
  387. await this.getLists();
  388. await this.getMaxSimulationTime();
  389. this.vehicleSelChange(res.info.vehicle);
  390. this.sceneSelChange(res.info.scene);
  391. } else {
  392. this.$message.error(res.message || "获取信息失败");
  393. }
  394. });
  395. }
  396. } else {
  397. this.getLists();
  398. this.getMaxSimulationTime();
  399. }
  400. },
  401. };
  402. </script>
  403. <style lang='less' scoped>
  404. .el-form {
  405. width: 60%;
  406. min-width: 900px;
  407. padding-top: 60px;
  408. margin: 0 auto;
  409. .formItemBox {
  410. flex: 1;
  411. /deep/ .el-input,
  412. .el-select,
  413. .el-cascader {
  414. width: 100%;
  415. }
  416. .el-cascader {
  417. height: 32px;
  418. line-height: 32px;
  419. }
  420. }
  421. .el-textarea {
  422. height: 96px;
  423. }
  424. .tipBox {
  425. min-width: 270px;
  426. margin-left: 20px;
  427. .tip {
  428. margin-bottom: 22px;
  429. line-height: 32px;
  430. }
  431. .tipA {
  432. height: 32px;
  433. // 按54往上加
  434. margin-top: 226px;
  435. .iconA {
  436. background: url("../../assets/common/image/sensor/001.png") center no-repeat;
  437. background-size: contain;
  438. }
  439. .iconB {
  440. background: url("../../assets/common/image/sensor/002.png") center no-repeat;
  441. background-size: contain;
  442. }
  443. .iconC {
  444. background: url("../../assets/common/image/sensor/003.png") center no-repeat;
  445. background-size: contain;
  446. }
  447. .iconD {
  448. background: url("../../assets/common/image/sensor/004.png") center no-repeat;
  449. background-size: contain;
  450. }
  451. .iconE {
  452. background: url("../../assets/common/image/sensor/005.png") center no-repeat;
  453. background-size: contain;
  454. }
  455. span {
  456. display: inline-block;
  457. width: 18px;
  458. height: 18px;
  459. margin-top: 7px;
  460. margin-right: 6px;
  461. }
  462. }
  463. .tipB {
  464. padding-top: 54px;
  465. }
  466. .tipBtnBox {
  467. margin-left: 20px;
  468. }
  469. }
  470. }
  471. .ruleTip {
  472. width: 60%;
  473. min-width: 900px;
  474. margin: 0 auto;
  475. a {
  476. color: @themeColor;
  477. }
  478. }
  479. .btns {
  480. padding-top: 30px;
  481. text-align: center;
  482. }
  483. </style>