machine_list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :exportList="exportList"
  6. :optionsEvensGroup="optionsEvensGroup"
  7. :operation="operation()"
  8. :tableEvents="tableEvents"
  9. :tableAttributes="tableAttributes"
  10. :columnParsing="columnParsing"
  11. >
  12. <!-- 弹窗 -->
  13. <el-dialog
  14. title="产品信息"
  15. :visible.sync="showDialogForm"
  16. width="30%"
  17. :show-close="false"
  18. :close-on-click-modal="false"
  19. >
  20. <el-form ref="diaLogForm" :model="diaLogForm" label-width="70px" :rules="rules" label-position="left">
  21. <el-form-item label="类型" prop="type">
  22. <el-select v-model="diaLogForm.type" filterable placeholder="请选择">
  23. <el-option v-for="item in distList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="名称" prop="name">
  28. <el-input v-model="diaLogForm.name" size="normal"></el-input>
  29. </el-form-item>
  30. <el-form-item label="型号" prop="model">
  31. <el-input v-model="diaLogForm.model" size="normal"></el-input>
  32. </el-form-item>
  33. <el-form-item label="编码" prop="number">
  34. <el-input v-model="diaLogForm.number" size="normal"></el-input>
  35. </el-form-item>
  36. <el-form-item label="体积" prop="volume">
  37. <el-input
  38. v-model.number="diaLogForm.volume"
  39. type="number"
  40. @mousewheel.native.prevent
  41. size="normal"
  42. ></el-input>
  43. </el-form-item>
  44. </el-form>
  45. <div slot="footer" class="dialog-footer">
  46. <el-button @click=";(showDialogForm = false), resetForm(), resetInfo()">取 消</el-button>
  47. <el-button type="primary" @click="hanleInfo">确 定</el-button>
  48. </div>
  49. </el-dialog>
  50. </template-page>
  51. </template>
  52. <script>
  53. import TemplatePage from '@/components/template/template-page-1.vue'
  54. import import_mixin from '@/components/template/import_mixin.js'
  55. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  56. import Popu from '@/components/template/popu.vue'
  57. import { downloadFiles, handleImport } from '@/utils/util'
  58. import {
  59. getDistList,
  60. getMachineAdd,
  61. getMachineDel,
  62. getMachineEdit,
  63. getMachineLlistV2,
  64. exportMachineLlistV2
  65. } from '@/api/basic_data/material'
  66. export default {
  67. components: { TemplatePage, Popu },
  68. mixins: [import_mixin, add_callback_mixin],
  69. data() {
  70. return {
  71. visible: false,
  72. // 事件组合
  73. // 事件组合
  74. optionsEvensGroup: [
  75. [
  76. [
  77. {
  78. name: '新增',
  79. click: this.addOn(() => {
  80. this.showDialogForm = true
  81. this.type = 1
  82. }),
  83. isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  84. }
  85. ]
  86. ],
  87. [
  88. [
  89. {
  90. name: '批量删除',
  91. click: async () => {
  92. if (this.recordSelected.length === 0) {
  93. this.$message.error('请选择需要删除的数据')
  94. return
  95. }
  96. let ids = this.recordSelected.map(v => {
  97. return v.id
  98. })
  99. let params = ids
  100. await getMachineDel(params)
  101. this.$refs.pageRef.refreshList()
  102. this.$message.success('批量删除成功')
  103. },
  104. isRole: this.$checkBtnRole('del', this.$route.meta.roles)
  105. }
  106. ]
  107. ]
  108. // [
  109. // [
  110. // {
  111. // name: '导入模版',
  112. // click: () => {
  113. // materialCategoryTemplateExcel({}, `${this.$route.meta.title}`)
  114. // .then(res => {
  115. // this.$message({
  116. // message: '下载成功',
  117. // type: 'success'
  118. // })
  119. // })
  120. // .catch(err => {
  121. // this.$message.error('下载失败')
  122. // })
  123. // }
  124. // }
  125. // ]
  126. // ],
  127. // [
  128. // [
  129. // {
  130. // name: '导出',
  131. // click: () => {
  132. // materialCategoryTemplateExcel({}, `${this.$route.meta.title}`)
  133. // .then(res => {
  134. // this.$message({
  135. // message: '下载成功',
  136. // type: 'success'
  137. // })
  138. // })
  139. // .catch(err => {
  140. // this.$message.error('下载失败')
  141. // })
  142. // }
  143. // }
  144. // ]
  145. // ]
  146. ],
  147. // 表格属性
  148. tableAttributes: {
  149. // 启用勾选列
  150. selectColumn: true
  151. }, // 关闭新增弹窗
  152. // 表格事件
  153. tableEvents: {
  154. 'selection-change': this.selectionChange
  155. },
  156. currentPage: 1, // 当前页码
  157. pageSize: 10, // 每页数量
  158. listTotal: 0, // 列表总数
  159. options: [
  160. {
  161. value: '选项1',
  162. label: '1'
  163. },
  164. {
  165. value: '选项2',
  166. label: '2'
  167. },
  168. {
  169. value: '选项3',
  170. label: '3'
  171. },
  172. {
  173. value: '选项4',
  174. label: '4'
  175. },
  176. {
  177. value: '选项5',
  178. label: '5'
  179. }
  180. ],
  181. diaLogForm: {
  182. id: null,
  183. name: '',
  184. number: '',
  185. model: '',
  186. volume: '',
  187. type: ''
  188. },
  189. showDialogForm: false,
  190. dataList: [],
  191. screenForm: {
  192. model: '',
  193. name: '',
  194. number: '',
  195. type: '',
  196. volume: ''
  197. },
  198. type: null,
  199. distList: [],
  200. rules: {
  201. type: [{ required: true, message: '请选择类型', trigger: 'blur' }],
  202. name: [{ required: true, message: '请选择名称', trigger: 'blur' }],
  203. model: [{ required: true, message: '请输入型号', trigger: 'blur' }],
  204. number: [{ required: true, message: '请输入编码', trigger: 'blur' }],
  205. volume: [
  206. {
  207. required: true,
  208. message: '请输入体积',
  209. type: 'number',
  210. trigger: 'blur'
  211. }
  212. ]
  213. }
  214. }
  215. },
  216. created() {
  217. getDistList({ sysDictEnum: 'MACHINE_CONFIGURE' }).then(res => {
  218. this.distList = res.data
  219. console.log(res, 123)
  220. })
  221. },
  222. methods: {
  223. // 列表请求函数
  224. getList(...p) {
  225. this.recordSelected = []
  226. return getMachineLlistV2(...p)
  227. },
  228. // 列表导出函数
  229. exportList: exportMachineLlistV2,
  230. // 表格列解析渲染数据更改
  231. columnParsing(item, defaultData) {
  232. return defaultData
  233. },
  234. // 监听勾选变化
  235. selectionChange(data) {
  236. this.recordSelected = data
  237. },
  238. operation() {
  239. return (h, { row, index, column }) => {
  240. return (
  241. <div class="operation-btns">
  242. {this.$checkBtnRole('edit', this.$route.meta.roles) ? (
  243. <el-button type="text" class="textColor" onClick={() => this.editFn(row.id, row)}>
  244. 编辑
  245. </el-button>
  246. ) : null}
  247. {this.$checkBtnRole('del', this.$route.meta.roles) ? (
  248. <el-popconfirm
  249. confirm-button-text="好的"
  250. cancel-button-text="不用了"
  251. icon="el-icon-info"
  252. icon-color="red"
  253. title="内容确定删除吗?"
  254. onOnConfirm={() => this.hanleDeleteAll(row.id)}
  255. >
  256. <el-button slot="reference" type="text" class="textColor el-popover-left">
  257. 删除
  258. </el-button>
  259. </el-popconfirm>
  260. ) : null}
  261. </div>
  262. )
  263. }
  264. },
  265. handleClose() {
  266. this.addOff(() => {
  267. this.visible = false
  268. })()
  269. },
  270. editFn(id, row) {
  271. this.type = 2
  272. this.diaLogForm = {
  273. id,
  274. name: row.name,
  275. number: row.number,
  276. model: row.model,
  277. volume: row.volume,
  278. type: row.type
  279. }
  280. this.showDialogForm = true
  281. },
  282. resetForm(formName) {
  283. this.$refs.diaLogForm.resetFields()
  284. },
  285. hanleInfo() {
  286. console.log(this.diaLogForm)
  287. this.$refs.diaLogForm.validate(valid => {
  288. if (valid) {
  289. if (this.type === 1) {
  290. getMachineAdd(this.diaLogForm).then(res => {
  291. this.$successMsg('保存成功')
  292. this.showDialogForm = false
  293. this.resetInfo()
  294. this.$refs.pageRef.refreshList()
  295. })
  296. } else if (this.type === 2) {
  297. const params = {
  298. ...this.diaLogForm
  299. }
  300. getMachineEdit(params).then(res => {
  301. this.$successMsg('编辑成功')
  302. this.showDialogForm = false
  303. this.resetInfo()
  304. this.$refs.pageRef.refreshList()
  305. })
  306. this.diaLogForm.id = null
  307. }
  308. } else {
  309. console.log('error submit!!')
  310. return false
  311. }
  312. })
  313. },
  314. // 导入
  315. async handleImport(param) {
  316. this.importLoading = true
  317. const file = param.file
  318. console.log(file, 123)
  319. const formData = new FormData()
  320. formData.append('file', file)
  321. let result = await handleImport('stock/importToll', formData)
  322. this.importLoading = false
  323. this.importFileList = []
  324. if (result.code == 200) {
  325. this.$alert(result.message, '导入成功', {
  326. confirmButtonText: '确定'
  327. })
  328. this.$refs.pageRef.refreshList()
  329. } else {
  330. this.$alert(result.message, '导入失败', {
  331. confirmButtonText: '确定'
  332. })
  333. }
  334. },
  335. handleExport() {
  336. let screenData = {
  337. customerName: this.screenForm.customerName,
  338. freeDay: this.screenForm.freeDay,
  339. toll: this.screenForm.toll
  340. }
  341. downloadFiles('machine-record/export', screenData)
  342. },
  343. hanleDeleteAll(id) {
  344. const ids = [id]
  345. getMachineDel(ids).then(res => {
  346. this.$refs.pageRef.refreshList()
  347. })
  348. },
  349. resetInfo() {
  350. this.diaLogForm = {
  351. id: null,
  352. innerMachineName: '',
  353. innerMachineNumber: '',
  354. innerMachineType: '',
  355. innerMachineVolume: 2,
  356. orgNumber: '4564',
  357. outsideMachineName: '',
  358. outsideMachineNumber: '',
  359. outsideMachineType: '',
  360. outsideMachineVolume: 2
  361. }
  362. },
  363. findMachineType(val) {
  364. const obj = this.distList.find(value => value.dictCode === val)
  365. return obj ? obj.dictValue : ''
  366. }
  367. }
  368. }
  369. </script>
  370. <style lang="scss" scoped>
  371. ::v-deep .el-select {
  372. width: 100%;
  373. }
  374. .import-btn {
  375. display: inline-block;
  376. margin-right: 10px;
  377. }
  378. </style>