machine_list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div>
  5. <el-form
  6. ref="screenForm"
  7. :model="screenForm"
  8. label-width="70px"
  9. size="small"
  10. label-position="left"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="12" :lg="6">
  14. <el-form-item label="名称" prop="name">
  15. <el-input
  16. placeholder="请输入名称"
  17. v-model="screenForm.name"
  18. ></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="6">
  22. <el-form-item label="型号" prop="model">
  23. <el-input
  24. placeholder="请输入型号"
  25. v-model="screenForm.model"
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="12" :lg="6">
  30. <el-form-item label="编码" prop="number">
  31. <el-input
  32. placeholder="请输入编码"
  33. v-model="screenForm.number"
  34. ></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :xs="24" :sm="12" :lg="6">
  38. <el-form-item label="体积" prop="volume">
  39. <el-input
  40. type="number"
  41. placeholder="请输入体积"
  42. v-model.number="screenForm.volume"
  43. ></el-input>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :xs="24" :sm="24" :lg="24" class="tr">
  47. <el-form-item label="">
  48. <el-button size="small" @click="resetScreenForm">清空</el-button>
  49. <el-button size="small" type="primary" @click="submitScreenForm"
  50. >搜索</el-button
  51. >
  52. </el-form-item>
  53. </el-col>
  54. </el-row>
  55. </el-form>
  56. </div>
  57. <!-- 按钮 -->
  58. <div class="btn-group clearfix">
  59. <div class="fl">
  60. <el-button
  61. v-if="$checkBtnRole('add', $route.meta.roles)"
  62. type="primary"
  63. size="small"
  64. icon="el-icon-plus"
  65. @click="(showDialogForm = true), (type = 1)"
  66. >新增</el-button
  67. >
  68. <el-popconfirm
  69. v-if="$checkBtnRole('del', $route.meta.roles)"
  70. confirm-button-text="好的"
  71. cancel-button-text="不用了"
  72. icon="el-icon-info"
  73. icon-color="red"
  74. :show-file-list="false"
  75. title="内容确定删除吗?"
  76. @onConfirm="hanleDeleteAll"
  77. >
  78. <el-button
  79. slot="reference"
  80. type="primary"
  81. icon="el-icon-delete"
  82. size="small"
  83. class="textColor el-popover-left"
  84. >删除</el-button
  85. >
  86. </el-popconfirm>
  87. </div>
  88. <div class="fr">
  89. <!-- <el-upload
  90. class="import-btn upload-demo"
  91. :action="baseURL + 'student/import'"
  92. :http-request="handleImport"
  93. :file-list="importFileList"
  94. :show-file-list="false"
  95. >
  96. <el-button type="primary" size="small">导入</el-button>
  97. </el-upload> -->
  98. <el-button type="primary" size="small" @click="handleExport"
  99. >导出</el-button
  100. >
  101. <!-- <el-button
  102. type="primary"
  103. size="small"
  104. icon="el-icon-printer"
  105. v-print="printObj"
  106. >打 印</el-button
  107. > -->
  108. </div>
  109. </div>
  110. <div class="mymain-container" id="printMe">
  111. <!-- 列表 -->
  112. <div class="table">
  113. <el-table
  114. v-loading="listLoading"
  115. :data="dataList"
  116. element-loading-text="Loading"
  117. border
  118. fit
  119. highlight-current-row
  120. @select-all="hanleSelectAll"
  121. @select="hanleSelectAll"
  122. stripe
  123. >
  124. <el-table-column type="selection" align="left"></el-table-column>
  125. <el-table-column
  126. align="left"
  127. label="类型"
  128. prop="type"
  129. min-width="160"
  130. show-overflow-tooltip
  131. >
  132. <template slot-scope="scope">
  133. {{ findMachineType(scope.row.type) }}
  134. </template>
  135. </el-table-column>
  136. <el-table-column
  137. align="left"
  138. label="名称"
  139. prop="name"
  140. min-width="160"
  141. show-overflow-tooltip
  142. ></el-table-column>
  143. <el-table-column
  144. align="left"
  145. label="型号"
  146. prop="model"
  147. min-width="160"
  148. show-overflow-tooltip
  149. ></el-table-column>
  150. <el-table-column
  151. align="left"
  152. label="编码"
  153. prop="number"
  154. min-width="160"
  155. show-overflow-tooltip
  156. ></el-table-column>
  157. <el-table-column
  158. align="right"
  159. label="体积"
  160. prop="volume"
  161. min-width="160"
  162. show-overflow-tooltip
  163. ></el-table-column>
  164. <el-table-column
  165. align="left"
  166. label="创建人"
  167. prop="createBy"
  168. min-width="160"
  169. show-overflow-tooltip
  170. ></el-table-column>
  171. <el-table-column
  172. align="left"
  173. label="创建时间"
  174. prop="createTime"
  175. min-width="160"
  176. show-overflow-tooltip
  177. ></el-table-column>
  178. <el-table-column
  179. align="left"
  180. label="更新人"
  181. prop="updateBy"
  182. min-width="160"
  183. show-overflow-tooltip
  184. ></el-table-column>
  185. <el-table-column
  186. align="left"
  187. label="更新时间"
  188. prop="updateTime"
  189. min-width="160"
  190. show-overflow-tooltip
  191. ></el-table-column>
  192. <el-table-column
  193. align="center"
  194. fixed="right"
  195. label="操作"
  196. min-width="160"
  197. show-overflow-tooltip
  198. >
  199. <template slot-scope="scope">
  200. <el-button
  201. v-if="$checkBtnRole('edit', $route.meta.roles)"
  202. type="text"
  203. class="textColor"
  204. @click="editFn(scope.row.id, scope.row)"
  205. >编辑</el-button
  206. >
  207. <el-popconfirm
  208. v-if="$checkBtnRole('del', $route.meta.roles)"
  209. confirm-button-text="好的"
  210. cancel-button-text="不用了"
  211. icon="el-icon-info"
  212. icon-color="red"
  213. title="内容确定删除吗?"
  214. @onConfirm="hanleDeleteAll(scope.row.id)"
  215. >
  216. <el-button
  217. slot="reference"
  218. type="text"
  219. class="textColor el-popover-left"
  220. >删除</el-button
  221. >
  222. </el-popconfirm>
  223. </template>
  224. </el-table-column>
  225. </el-table>
  226. </div>
  227. <!-- 分页 -->
  228. <div class="fr">
  229. <el-pagination
  230. @size-change="handleSizeChange"
  231. @current-change="handleCurrentChange"
  232. :current-page="currentPage"
  233. :page-sizes="[10, 20, 30, 50]"
  234. :page-size="10"
  235. layout="total, sizes, prev, pager, next, jumper"
  236. :total="listTotal"
  237. >
  238. </el-pagination>
  239. </div>
  240. </div>
  241. <!-- 弹窗 -->
  242. <el-dialog
  243. title="产品信息"
  244. :visible.sync="showDialogForm"
  245. width="30%"
  246. :show-close="false"
  247. :close-on-click-modal="false"
  248. >
  249. <el-form
  250. ref="diaLogForm"
  251. :model="diaLogForm"
  252. label-width="70px"
  253. :rules="rules"
  254. size="small"
  255. label-position="left"
  256. >
  257. <el-form-item label="类型" prop="type">
  258. <el-select v-model="diaLogForm.type" filterable placeholder="请选择">
  259. <el-option
  260. v-for="item in distList"
  261. :key="item.dictCode"
  262. :label="item.dictValue"
  263. :value="item.dictCode"
  264. >
  265. </el-option>
  266. </el-select>
  267. </el-form-item>
  268. <el-form-item label="名称" prop="name">
  269. <el-input v-model="diaLogForm.name" size="normal"></el-input>
  270. </el-form-item>
  271. <el-form-item label="型号" prop="model">
  272. <el-input v-model="diaLogForm.model" size="normal"></el-input>
  273. </el-form-item>
  274. <el-form-item label="编码" prop="number">
  275. <el-input v-model="diaLogForm.number" size="normal"></el-input>
  276. </el-form-item>
  277. <el-form-item label="体积" prop="volume">
  278. <el-input
  279. v-model="diaLogForm.volume"
  280. type="number"
  281. size="normal"
  282. ></el-input>
  283. </el-form-item>
  284. </el-form>
  285. <div slot="footer" class="dialog-footer">
  286. <el-button @click="(showDialogForm = false), resetForm(), resetInfo()"
  287. >取 消</el-button
  288. >
  289. <el-button type="primary" @click="hanleInfo">确 定</el-button>
  290. </div>
  291. </el-dialog>
  292. </div>
  293. </template>
  294. <script>
  295. import Mixin from '@/mixin/index'
  296. import { downloadFiles, handleImport } from '@/utils/util'
  297. import { getDistList, getMachineAdd, getMachineDel, getMachineEdit, getMachineLlist } from '@/api/basic_data/material'
  298. import print from 'vue-print-nb'
  299. export default {
  300. mixins: [Mixin],
  301. directives: {
  302. print,
  303. },
  304. data() {
  305. return {
  306. printObj: {
  307. id: "printMe",
  308. },
  309. currentPage: 1, // 当前页码
  310. pageSize: 10, // 每页数量
  311. listTotal: 0, // 列表总数
  312. options: [
  313. {
  314. value: "选项1",
  315. label: "1",
  316. },
  317. {
  318. value: "选项2",
  319. label: "2",
  320. },
  321. {
  322. value: "选项3",
  323. label: "3",
  324. },
  325. {
  326. value: "选项4",
  327. label: "4",
  328. },
  329. {
  330. value: "选项5",
  331. label: "5",
  332. },
  333. ],
  334. diaLogForm: {
  335. id: null,
  336. name: "",
  337. number: "",
  338. model: "",
  339. volume: "",
  340. type: "",
  341. },
  342. showDialogForm: false,
  343. dataList: [],
  344. screenForm: {
  345. model: "",
  346. name: "",
  347. number: "",
  348. type: "",
  349. volume: "",
  350. },
  351. type: null,
  352. distList: [],
  353. rules: {
  354. type: [{ required: true, message: "请选择类型", trigger: "blur" }],
  355. name: [{ required: true, message: "请选择名称", trigger: "blur" }],
  356. model: [{ required: true, message: "请输入型号", trigger: "blur" }],
  357. number: [{ required: true, message: "请输入编码", trigger: "blur" }],
  358. volume: [
  359. {
  360. required: true,
  361. message: "请输入体积",
  362. type: "number",
  363. trigger: "blur",
  364. },
  365. ],
  366. },
  367. };
  368. },
  369. created() {
  370. getDistList({ sysDictEnum: "MACHINE_CONFIGURE" }).then((res) => {
  371. this.distList = res.data;
  372. console.log(res, 123);
  373. });
  374. },
  375. methods: {
  376. editFn(id, row) {
  377. this.type = 2;
  378. this.diaLogForm = {
  379. id,
  380. name: row.name,
  381. number: row.number,
  382. model: row.model,
  383. volume: row.volume,
  384. type: row.type,
  385. };
  386. this.showDialogForm = true;
  387. },
  388. resetForm(formName) {
  389. this.$refs.diaLogForm.resetFields();
  390. },
  391. hanleInfo() {
  392. this.$refs.diaLogForm.validate((valid) => {
  393. if (valid) {
  394. if (this.type === 1) {
  395. getMachineAdd(this.diaLogForm).then((res) => {
  396. this.$successMsg("保存成功");
  397. this.showDialogForm = false;
  398. this.resetInfo();
  399. this.getList();
  400. });
  401. } else if (this.type === 2) {
  402. const params = {
  403. ...this.diaLogForm,
  404. };
  405. getMachineEdit(params).then((res) => {
  406. this.$successMsg("编辑成功");
  407. this.showDialogForm = false;
  408. this.resetInfo();
  409. this.getList();
  410. });
  411. this.diaLogForm.id = null;
  412. }
  413. } else {
  414. console.log("error submit!!");
  415. return false;
  416. }
  417. });
  418. },
  419. // 初始化数据
  420. getList() {
  421. this.listLoading = true;
  422. let params = {
  423. pageNum: this.currentPage,
  424. pageSize: this.pageSize,
  425. name: this.screenForm.name,
  426. number: this.screenForm.number,
  427. model: this.screenForm.model,
  428. volume: this.screenForm.volume,
  429. };
  430. getMachineLlist(params).then((res) => {
  431. this.dataList = res.data.records;
  432. this.listTotal = res.data.total;
  433. this.listLoading = false;
  434. console.log(this.dataList, 1233);
  435. });
  436. },
  437. // 导入
  438. async handleImport(param) {
  439. this.importLoading = true;
  440. const file = param.file;
  441. console.log(file, 123);
  442. const formData = new FormData();
  443. formData.append("file", file);
  444. let result = await handleImport("/stock/importToll", formData);
  445. this.importLoading = false;
  446. this.importFileList = [];
  447. if (result.code == 200) {
  448. this.$alert(result.message, "导入成功", {
  449. confirmButtonText: "确定",
  450. });
  451. this.getList();
  452. } else {
  453. this.$alert(result.message, "导入失败", {
  454. confirmButtonText: "确定",
  455. });
  456. }
  457. },
  458. handleExport() {
  459. let screenData = {
  460. customerName: this.screenForm.customerName,
  461. freeDay: this.screenForm.freeDay,
  462. toll: this.screenForm.toll,
  463. };
  464. downloadFiles("/machine-record/export", screenData);
  465. },
  466. hanleDeleteAll(id) {
  467. console.log(id);
  468. this.hanleDeleteAllPromise(id).then((ids) => {
  469. getMachineDel(ids).then((res) => {
  470. this.getList();
  471. });
  472. });
  473. },
  474. resetInfo() {
  475. this.diaLogForm = {
  476. id: null,
  477. innerMachineName: "",
  478. innerMachineNumber: "",
  479. innerMachineType: "",
  480. innerMachineVolume: 2,
  481. orgNumber: "4564",
  482. outsideMachineName: "",
  483. outsideMachineNumber: "",
  484. outsideMachineType: "",
  485. outsideMachineVolume: 2,
  486. };
  487. },
  488. findMachineType(val) {
  489. const obj = this.distList.find((value) => value.dictCode === val);
  490. return obj ? obj.dictValue : "";
  491. },
  492. },
  493. };
  494. </script>
  495. <style lang="scss" scoped>
  496. ::v-deep .el-select {
  497. width: 100%;
  498. }
  499. .import-btn {
  500. display: inline-block;
  501. margin-right: 10px;
  502. }
  503. </style>