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="mini"
  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" @mousewheel.native.prevent
  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="mini" @click="resetScreenForm">清空</el-button>
  49. <el-button size="mini" 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="mini"
  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="mini"
  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="mini">导入</el-button>
  97. </el-upload> -->
  98. <el-button type="primary" size="mini" @click="handleExport"
  99. >导出</el-button
  100. >
  101. <!-- <el-button
  102. type="primary"
  103. size="mini"
  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. label-position="left"
  255. >
  256. <el-form-item label="类型" prop="type">
  257. <el-select v-model="diaLogForm.type" filterable placeholder="请选择">
  258. <el-option
  259. v-for="item in distList"
  260. :key="item.dictCode"
  261. :label="item.dictValue"
  262. :value="item.dictCode"
  263. >
  264. </el-option>
  265. </el-select>
  266. </el-form-item>
  267. <el-form-item label="名称" prop="name">
  268. <el-input v-model="diaLogForm.name" size="normal"></el-input>
  269. </el-form-item>
  270. <el-form-item label="型号" prop="model">
  271. <el-input v-model="diaLogForm.model" size="normal"></el-input>
  272. </el-form-item>
  273. <el-form-item label="编码" prop="number">
  274. <el-input v-model="diaLogForm.number" size="normal"></el-input>
  275. </el-form-item>
  276. <el-form-item label="体积" prop="volume">
  277. <el-input
  278. v-model="diaLogForm.volume"
  279. type="number" @mousewheel.native.prevent
  280. size="normal"
  281. ></el-input>
  282. </el-form-item>
  283. </el-form>
  284. <div slot="footer" class="dialog-footer">
  285. <el-button @click="(showDialogForm = false), resetForm(), resetInfo()"
  286. >取 消</el-button
  287. >
  288. <el-button type="primary" @click="hanleInfo">确 定</el-button>
  289. </div>
  290. </el-dialog>
  291. </div>
  292. </template>
  293. <script>
  294. import Mixin from '@/mixin/index'
  295. import { downloadFiles, handleImport } from '@/utils/util'
  296. import { getDistList, getMachineAdd, getMachineDel, getMachineEdit, getMachineLlist } from '@/api/basic_data/material'
  297. import print from 'vue-print-nb'
  298. export default {
  299. mixins: [Mixin],
  300. directives: {
  301. print,
  302. },
  303. data() {
  304. return {
  305. printObj: {
  306. id: "printMe",
  307. },
  308. currentPage: 1, // 当前页码
  309. pageSize: 10, // 每页数量
  310. listTotal: 0, // 列表总数
  311. options: [
  312. {
  313. value: "选项1",
  314. label: "1",
  315. },
  316. {
  317. value: "选项2",
  318. label: "2",
  319. },
  320. {
  321. value: "选项3",
  322. label: "3",
  323. },
  324. {
  325. value: "选项4",
  326. label: "4",
  327. },
  328. {
  329. value: "选项5",
  330. label: "5",
  331. },
  332. ],
  333. diaLogForm: {
  334. id: null,
  335. name: "",
  336. number: "",
  337. model: "",
  338. volume: "",
  339. type: "",
  340. },
  341. showDialogForm: false,
  342. dataList: [],
  343. screenForm: {
  344. model: "",
  345. name: "",
  346. number: "",
  347. type: "",
  348. volume: "",
  349. },
  350. type: null,
  351. distList: [],
  352. rules: {
  353. type: [{ required: true, message: "请选择类型", trigger: "blur" }],
  354. name: [{ required: true, message: "请选择名称", trigger: "blur" }],
  355. model: [{ required: true, message: "请输入型号", trigger: "blur" }],
  356. number: [{ required: true, message: "请输入编码", trigger: "blur" }],
  357. volume: [
  358. {
  359. required: true,
  360. message: "请输入体积",
  361. type: "number",
  362. trigger: "blur",
  363. },
  364. ],
  365. },
  366. };
  367. },
  368. created() {
  369. getDistList({ sysDictEnum: "MACHINE_CONFIGURE" }).then((res) => {
  370. this.distList = res.data;
  371. console.log(res, 123);
  372. });
  373. },
  374. methods: {
  375. editFn(id, row) {
  376. this.type = 2;
  377. this.diaLogForm = {
  378. id,
  379. name: row.name,
  380. number: row.number,
  381. model: row.model,
  382. volume: row.volume,
  383. type: row.type,
  384. };
  385. this.showDialogForm = true;
  386. },
  387. resetForm(formName) {
  388. this.$refs.diaLogForm.resetFields();
  389. },
  390. hanleInfo() {
  391. this.$refs.diaLogForm.validate((valid) => {
  392. if (valid) {
  393. if (this.type === 1) {
  394. getMachineAdd(this.diaLogForm).then((res) => {
  395. this.$successMsg("保存成功");
  396. this.showDialogForm = false;
  397. this.resetInfo();
  398. this.getList();
  399. });
  400. } else if (this.type === 2) {
  401. const params = {
  402. ...this.diaLogForm,
  403. };
  404. getMachineEdit(params).then((res) => {
  405. this.$successMsg("编辑成功");
  406. this.showDialogForm = false;
  407. this.resetInfo();
  408. this.getList();
  409. });
  410. this.diaLogForm.id = null;
  411. }
  412. } else {
  413. console.log("error submit!!");
  414. return false;
  415. }
  416. });
  417. },
  418. // 初始化数据
  419. getList() {
  420. this.listLoading = true;
  421. let params = {
  422. pageNum: this.currentPage,
  423. pageSize: this.pageSize,
  424. name: this.screenForm.name,
  425. number: this.screenForm.number,
  426. model: this.screenForm.model,
  427. volume: this.screenForm.volume,
  428. };
  429. getMachineLlist(params).then((res) => {
  430. this.dataList = res.data.records;
  431. this.listTotal = res.data.total;
  432. this.listLoading = false;
  433. console.log(this.dataList, 1233);
  434. });
  435. },
  436. // 导入
  437. async handleImport(param) {
  438. this.importLoading = true;
  439. const file = param.file;
  440. console.log(file, 123);
  441. const formData = new FormData();
  442. formData.append("file", file);
  443. let result = await handleImport("/stock/importToll", formData);
  444. this.importLoading = false;
  445. this.importFileList = [];
  446. if (result.code == 200) {
  447. this.$alert(result.message, "导入成功", {
  448. confirmButtonText: "确定",
  449. });
  450. this.getList();
  451. } else {
  452. this.$alert(result.message, "导入失败", {
  453. confirmButtonText: "确定",
  454. });
  455. }
  456. },
  457. handleExport() {
  458. let screenData = {
  459. customerName: this.screenForm.customerName,
  460. freeDay: this.screenForm.freeDay,
  461. toll: this.screenForm.toll,
  462. };
  463. downloadFiles("/machine-record/export", screenData);
  464. },
  465. hanleDeleteAll(id) {
  466. console.log(id);
  467. this.hanleDeleteAllPromise(id).then((ids) => {
  468. getMachineDel(ids).then((res) => {
  469. this.getList();
  470. });
  471. });
  472. },
  473. resetInfo() {
  474. this.diaLogForm = {
  475. id: null,
  476. innerMachineName: "",
  477. innerMachineNumber: "",
  478. innerMachineType: "",
  479. innerMachineVolume: 2,
  480. orgNumber: "4564",
  481. outsideMachineName: "",
  482. outsideMachineNumber: "",
  483. outsideMachineType: "",
  484. outsideMachineVolume: 2,
  485. };
  486. },
  487. findMachineType(val) {
  488. const obj = this.distList.find((value) => value.dictCode === val);
  489. return obj ? obj.dictValue : "";
  490. },
  491. },
  492. };
  493. </script>
  494. <style lang="scss" scoped>
  495. ::v-deep .el-select {
  496. width: 100%;
  497. }
  498. .import-btn {
  499. display: inline-block;
  500. margin-right: 10px;
  501. }
  502. </style>