index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="68px"
  10. >
  11. <el-form-item label="指令编码" prop="orderCode">
  12. <el-input
  13. v-model="queryParams.orderCode"
  14. placeholder="请输入指令编码"
  15. clearable
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="指令名称" prop="name">
  20. <el-input
  21. v-model="queryParams.name"
  22. placeholder="请输入指令名称"
  23. clearable
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="指令描述" prop="description">
  28. <el-input
  29. v-model="queryParams.description"
  30. placeholder="请输入指令描述"
  31. clearable
  32. @keyup.enter.native="handleQuery"
  33. />
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button
  37. type="primary"
  38. icon="el-icon-search"
  39. size="mini"
  40. @click="handleQuery"
  41. >搜索</el-button
  42. >
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  44. >重置</el-button
  45. >
  46. </el-form-item>
  47. </el-form>
  48. <el-row :gutter="10" class="mb8">
  49. <el-col :span="1.5">
  50. <el-button
  51. type="primary"
  52. plain
  53. icon="el-icon-plus"
  54. size="mini"
  55. @click="handleAdd"
  56. v-hasPermi="['manage:orderConfig:add']"
  57. >新增</el-button
  58. >
  59. </el-col>
  60. <!-- <el-col :span="1.5">
  61. <el-button
  62. type="success"
  63. plain
  64. icon="el-icon-edit"
  65. size="mini"
  66. :disabled="single"
  67. @click="handleUpdate"
  68. v-hasPermi="['manage:orderConfig:edit']"
  69. >修改</el-button
  70. >
  71. </el-col> -->
  72. <el-col :span="1.5">
  73. <el-button
  74. type="danger"
  75. plain
  76. icon="el-icon-delete"
  77. size="mini"
  78. :disabled="multiple"
  79. @click="handleDelete"
  80. v-hasPermi="['manage:orderConfig:remove']"
  81. >删除</el-button
  82. >
  83. </el-col>
  84. <!-- <el-col :span="1.5">
  85. <el-button
  86. type="warning"
  87. plain
  88. icon="el-icon-download"
  89. size="mini"
  90. @click="handleExport"
  91. v-hasPermi="['manage:orderConfig:export']"
  92. >导出</el-button
  93. >
  94. </el-col> -->
  95. <el-col :span="1.5">
  96. <el-button
  97. type="warning"
  98. plain
  99. icon="el-icon-upload2"
  100. size="mini"
  101. @click="handleImport"
  102. v-hasPermi="['manage:orderConfig:export']"
  103. >导入</el-button
  104. >
  105. </el-col>
  106. <right-toolbar
  107. :showSearch.sync="showSearch"
  108. @queryTable="getList"
  109. ></right-toolbar>
  110. </el-row>
  111. <el-table
  112. v-loading="loading"
  113. border
  114. :data="orderConfigList"
  115. @selection-change="handleSelectionChange"
  116. >
  117. <el-table-column type="selection" width="55" align="center" />
  118. <el-table-column label="指令编码" align="center" prop="orderCode" />
  119. <el-table-column label="指令名称" align="center" prop="name">
  120. <template slot-scope="scope">
  121. <span class="query-c" @click="queryXml(scope.row)">{{
  122. scope.row.name
  123. }}</span>
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="指令类型" align="center" prop="type" />
  127. <el-table-column label="架次" align="center" prop="sortie" />
  128. <el-table-column label="步长" align="center" prop="step" />
  129. <el-table-column label="指令描述" align="center" prop="description" />
  130. <el-table-column label="更新人" align="center" prop="updateBy" />
  131. <el-table-column
  132. label="更新时间"
  133. align="center"
  134. prop="updateTime"
  135. width="180"
  136. >
  137. <template slot-scope="scope">
  138. <span>{{
  139. parseTime(scope.row.updateTime, "{y}-{m}-{d} {h}:{i}:{s}")
  140. }}</span>
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. label="操作"
  145. align="center"
  146. class-name="small-padding fixed-width"
  147. >
  148. <template slot-scope="scope">
  149. <el-button
  150. size="mini"
  151. type="text"
  152. icon="el-icon-edit"
  153. @click="handleUpdate(scope.row)"
  154. v-hasPermi="['manage:orderConfig:edit']"
  155. >修改</el-button
  156. >
  157. <el-button
  158. size="mini"
  159. type="text"
  160. icon="el-icon-delete"
  161. @click="handleDelete(scope.row)"
  162. v-hasPermi="['manage:orderConfig:remove']"
  163. >删除</el-button
  164. >
  165. </template>
  166. </el-table-column>
  167. </el-table>
  168. <pagination
  169. v-show="total > 0"
  170. :total="total"
  171. :page.sync="queryParams.pageNum"
  172. :limit.sync="queryParams.pageSize"
  173. @pagination="getList"
  174. />
  175. <!-- 添加或修改指令配置对话框 -->
  176. <el-dialog
  177. :title="title"
  178. :visible.sync="open"
  179. :close-on-click-modal="false"
  180. width="500px"
  181. append-to-body
  182. >
  183. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  184. <el-form-item label="指令编码" prop="orderCode">
  185. <el-input
  186. v-model="form.orderCode"
  187. placeholder="请输入指令编码"
  188. :disabled="form.id !== null"
  189. />
  190. </el-form-item>
  191. <el-form-item label="指令名称" prop="name">
  192. <el-select
  193. v-model="form.name"
  194. placeholder="请选择指令状态"
  195. style="width: 100%"
  196. @change="change"
  197. >
  198. <el-option
  199. v-for="dict in dict.type.order_type"
  200. :key="dict.value"
  201. :label="dict.label"
  202. :value="dict"
  203. ></el-option>
  204. </el-select>
  205. </el-form-item>
  206. <el-form-item label="架次" prop="sortie">
  207. <el-select
  208. v-model="form.sortie"
  209. allow-create
  210. filterable
  211. placeholder="请选择架次"
  212. style="width: 100%"
  213. >
  214. <el-option
  215. v-for="(item, index) in sortieArr"
  216. :key="index"
  217. :label="item.sortieNumber"
  218. :value="item.sortieNumber"
  219. ></el-option>
  220. </el-select>
  221. <!-- <el-input v-model="form.sortie" placeholder="请输入架次" /> -->
  222. </el-form-item>
  223. <el-form-item label="步长" prop="step">
  224. <el-input v-model="form.step" placeholder="请输入步长" />
  225. </el-form-item>
  226. <el-form-item label="指令描述" prop="description">
  227. <el-input v-model="form.description" placeholder="请输入指令描述" />
  228. </el-form-item>
  229. </el-form>
  230. <div slot="footer" class="dialog-footer">
  231. <el-button type="primary" @click="submitForm">确 定</el-button>
  232. <el-button @click="cancel">取 消</el-button>
  233. </div>
  234. </el-dialog>
  235. <!-- 添加或修改指令配置对话框 -->
  236. <el-dialog
  237. :title="title"
  238. :visible.sync="openXml"
  239. :close-on-click-modal="false"
  240. width="900px"
  241. append-to-body
  242. >
  243. <Editor :textContent="xmlText" :dataType="'XML'" v-if="openXml" @closeEditor="closeEditor" :isExport="true" />
  244. </el-dialog>
  245. <!-- 用户导入对话框 -->
  246. <el-dialog
  247. :title="upload.title"
  248. :visible.sync="upload.open"
  249. width="400px"
  250. append-to-body
  251. >
  252. <el-upload
  253. ref="upload"
  254. :limit="1"
  255. accept=".xm"
  256. :headers="upload.headers"
  257. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  258. :disabled="upload.isUploading"
  259. :on-progress="handleFileUploadProgress"
  260. :on-success="handleFileSuccess"
  261. :auto-upload="false"
  262. drag
  263. >
  264. <i class="el-icon-upload"></i>
  265. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  266. <div class="el-upload__tip text-center" slot="tip">
  267. <span>仅允许导入xml格式文件。</span>
  268. </div>
  269. </el-upload>
  270. <div slot="footer" class="dialog-footer">
  271. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  272. <el-button @click="upload.open = false">取 消</el-button>
  273. </div>
  274. </el-dialog>
  275. </div>
  276. </template>
  277. <script>
  278. import {
  279. listOrderConfig,
  280. getOrderConfig,
  281. delOrderConfig,
  282. addOrderConfig,
  283. updateOrderConfig,
  284. getOrderConfigXml,
  285. listSortie,
  286. } from "@/api/manage/orderConfig";
  287. import Editor from "@/views/manage/components/Editor";
  288. import { getToken } from "@/utils/auth";
  289. export default {
  290. name: "OrderConfig",
  291. components: {
  292. Editor,
  293. },
  294. dicts: ["order_type"],
  295. data() {
  296. return {
  297. // 遮罩层
  298. loading: true,
  299. // 选中数组
  300. ids: [],
  301. // 非单个禁用
  302. single: true,
  303. // 非多个禁用
  304. multiple: true,
  305. // 显示搜索条件
  306. showSearch: true,
  307. // 总条数
  308. total: 0,
  309. // 指令配置表格数据
  310. orderConfigList: [],
  311. // 弹出层标题
  312. title: "",
  313. // 是否显示弹出层
  314. open: false,
  315. // 是否显示弹出层
  316. openXml: false,
  317. // xml结果
  318. xmlText: "",
  319. // 查询参数
  320. queryParams: {
  321. pageNum: 1,
  322. pageSize: 10,
  323. id: null,
  324. orderCode: null,
  325. type: null,
  326. name: null,
  327. description: null,
  328. },
  329. // 表单参数
  330. form: {},
  331. // 表单校验
  332. rules: {
  333. orderCode: [
  334. { required: true, message: "指令编码不能为空", trigger: "blur" },
  335. ],
  336. name: [
  337. { required: true, message: "指令名称不能为空", trigger: "change" },
  338. ],
  339. },
  340. //自定义弹出框
  341. analysisDialog: false,
  342. //1是自定义的,0是列表信息进入的
  343. flag: 1,
  344. // 架次下拉框
  345. sortieArr: [],
  346. // 用户导入参数
  347. upload: {
  348. // 是否显示弹出层(用户导入)
  349. open: false,
  350. // 弹出层标题(用户导入)
  351. title: "",
  352. // 是否禁用上传
  353. isUploading: false,
  354. // 是否更新已经存在的用户数据
  355. updateSupport: 0,
  356. // 设置上传的请求头部
  357. headers: { Authorization: "Bearer " + getToken() },
  358. // 上传的地址
  359. url: process.env.VUE_APP_BASE_API + "/manage/orderConfig/import/xml"
  360. },
  361. };
  362. },
  363. created() {
  364. this.getList();
  365. },
  366. methods: {
  367. /** 导入按钮操作 */
  368. handleImport() {
  369. this.upload.title = "用户导入";
  370. this.upload.open = true;
  371. },
  372. change(val) {
  373. this.form.name = val.label || "";
  374. this.form.type = val.value || "";
  375. },
  376. /** 查询指令配置列表 */
  377. getList() {
  378. this.loading = true;
  379. listOrderConfig(this.queryParams).then((response) => {
  380. this.orderConfigList = response.rows;
  381. this.total = response.total;
  382. this.loading = false;
  383. });
  384. },
  385. // 取消按钮
  386. cancel() {
  387. this.open = false;
  388. this.reset();
  389. },
  390. // 自定义对话框关闭
  391. close() {
  392. this.analysisDialog = false;
  393. },
  394. // 关闭编辑器
  395. closeEditor(value) {
  396. if (value === 'no') {
  397. this.openXml = false
  398. } else {
  399. this.$modal
  400. .confirm('是否确认更改内容')
  401. .then(() => {
  402. this.openXml = false
  403. this.$modal.msgSuccess('修改成功')
  404. })
  405. .catch(() => {})
  406. }
  407. },
  408. // 表单重置
  409. reset() {
  410. this.form = {
  411. id: null,
  412. orderCode: null,
  413. name: null,
  414. sortie: null,
  415. step: null,
  416. type: null,
  417. description: null,
  418. };
  419. this.resetForm("form");
  420. },
  421. /** 搜索按钮操作 */
  422. handleQuery() {
  423. this.queryParams.pageNum = 1;
  424. this.getList();
  425. },
  426. /** 重置按钮操作 */
  427. resetQuery() {
  428. this.resetForm("queryForm");
  429. this.handleQuery();
  430. },
  431. // 多选框选中数据
  432. handleSelectionChange(selection) {
  433. this.ids = selection.map((item) => item.id);
  434. this.single = selection.length !== 1;
  435. this.multiple = !selection.length;
  436. },
  437. /** 新增按钮操作 */
  438. handleAdd() {
  439. this.reset();
  440. this.findListSortie();
  441. this.open = true;
  442. this.title = "添加指令配置";
  443. },
  444. /** 修改按钮操作 */
  445. handleUpdate(row) {
  446. this.reset();
  447. const id = row.id || this.ids;
  448. getOrderConfig(id).then((response) => {
  449. this.form = response.data;
  450. this.open = true;
  451. this.title = "修改指令配置";
  452. this.findListSortie();
  453. });
  454. },
  455. findListSortie() {
  456. listSortie({}).then((response) => {
  457. this.sortieArr = response.data;
  458. console.log(response);
  459. });
  460. },
  461. /** 查询 */
  462. queryXml(row) {
  463. this.reset();
  464. const id = row.id || this.ids;
  465. getOrderConfigXml(id).then((response) => {
  466. this.xmlText = response.data;
  467. // XML
  468. console.log("response", response.data);
  469. this.openXml = true;
  470. this.title = "XML详情";
  471. });
  472. },
  473. /** 提交按钮 */
  474. submitForm() {
  475. this.$refs["form"].validate((valid) => {
  476. if (valid) {
  477. if (this.form.id != null) {
  478. updateOrderConfig(this.form).then((response) => {
  479. this.$modal.msgSuccess("修改成功");
  480. this.open = false;
  481. this.getList();
  482. });
  483. } else {
  484. addOrderConfig(this.form).then((response) => {
  485. this.$modal.msgSuccess("新增成功");
  486. this.open = false;
  487. this.getList();
  488. });
  489. }
  490. }
  491. });
  492. },
  493. /** 删除按钮操作 */
  494. handleDelete(row) {
  495. const IDs = row.id || this.ids;
  496. this.$modal
  497. .confirm('是否确认删除指令配置编号为"' + IDs + '"的数据项?')
  498. .then(function () {
  499. return delOrderConfig(IDs);
  500. })
  501. .then(() => {
  502. this.getList();
  503. this.$modal.msgSuccess("删除成功");
  504. })
  505. .catch(() => {});
  506. },
  507. /** 导出按钮操作 */
  508. handleExport() {
  509. this.download(
  510. "manage/orderConfig/export",
  511. {
  512. ...this.queryParams,
  513. },
  514. `orderConfig_${new Date().getTime()}.xlsx`
  515. );
  516. },
  517. // 文件上传中处理
  518. handleFileUploadProgress(event, file, fileList) {
  519. this.upload.isUploading = true;
  520. },
  521. // 文件上传成功处理
  522. handleFileSuccess(response, file, fileList) {
  523. this.upload.open = false;
  524. this.upload.isUploading = false;
  525. this.$refs.upload.clearFiles();
  526. this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
  527. this.getList();
  528. },
  529. // 提交上传文件
  530. submitFileForm() {
  531. this.$refs.upload.submit();
  532. }
  533. },
  534. };
  535. </script>
  536. <style scoped>
  537. .query-c {
  538. color: #1890ff;
  539. cursor: pointer;
  540. }
  541. </style>