machine_list.vue 13 KB

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