encoderList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <div>
  3. <a-card :bordered="false" class="top" style="margin-bottom:1%;margin-top:1%">
  4. <!-- 查询区域 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="searchQuery">
  7. <a-row :gutter="24">
  8. <a-col :md="4" :sm="24">
  9. <a-form-item label="料品名称">
  10. <a-input placeholder="请输入" v-model="queryParam.inventoryName" ></a-input>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="4" :sm="24">
  14. <a-form-item label="料品类别">
  15. <a-input placeholder="请输入" v-model="queryParam.classifyName"></a-input>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="4" :sm="24">
  19. <a-form-item label="料品主单位">
  20. <a-input placeholder="请输入" v-model="queryParam.unit" ></a-input>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="4" :sm="24">
  24. <a-form-item label="料品单位">
  25. <a-input placeholder="请输入" v-model="queryParam.auxiliaryUnit"></a-input>
  26. </a-form-item>
  27. </a-col>
  28. <template v-if="toggleSearchStatus">
  29. <a-col :md="4" :sm="24">
  30. <a-form-item label="颜色">
  31. <a-input placeholder="请输入" v-model="queryParam.color" ></a-input>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="4" :sm="24">
  35. <a-form-item label="宽/高">
  36. <a-input placeholder="请输入" v-model="queryParam.widthHeight"></a-input>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="4" :sm="24">
  40. <a-form-item label="支长">
  41. <a-input placeholder="请输入" v-model="queryParam.fixedLength"></a-input>
  42. </a-form-item>
  43. </a-col>
  44. <a-col :md="4" :sm="24">
  45. <a-form-item label="料品属性">
  46. <a-input placeholder="请输入" v-model="queryParam.attribute"></a-input>
  47. </a-form-item>
  48. </a-col>
  49. </template>
  50. <a-col :md="4" :sm="24">
  51. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  52. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  53. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  54. <a @click="handleToggleSearch" style="margin-left: 8px">
  55. {{ toggleSearchStatus ? '收起' : '展开' }}
  56. <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
  57. </a>
  58. </span>
  59. </a-col>
  60. </a-row>
  61. </a-form>
  62. </div>
  63. </a-card>
  64. <a-card class="middle" style="margin-bottom:1%">
  65. <!-- 操作按钮区域 -->
  66. <div class="table-operator">
  67. <a-button type="danger" size="small" @click='addList'>新增</a-button>
  68. <a-button size="small" @click='editList'>修改</a-button>
  69. <a-button type="danger" size="small" @click="delectList">删除</a-button>
  70. <a-button size="small" @click="detailList">详情</a-button>
  71. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" @change="handleUploadChange" :action="fileUpload">
  72. <a-button size="small">导入</a-button>
  73. </a-upload>
  74. <a-button size="small" @click="exportList('编码器列表')">导出</a-button>
  75. <a-button size="small" @click="syncList">同步至u9</a-button>
  76. </div>
  77. <!-- table区域-begin -->
  78. <div>
  79. <a-table
  80. ref="table"
  81. size="middle"
  82. bordered
  83. rowKey="id"
  84. :columns="columns"
  85. :dataSource="dataSource"
  86. :pagination="ipagination"
  87. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  88. @change="handleTableChange"
  89. :customRow ="clickRow"
  90. >
  91. <!-- :scroll="{ x: 1500, y: 300 }" -->
  92. </a-table>
  93. </div>
  94. <AddEncoder ref="AddEncoder" @ok="getTableList"></AddEncoder>
  95. <EncoderDetail ref="EncoderDetail" @ok="getTableList"></EncoderDetail>
  96. </a-card>
  97. </div>
  98. </template>
  99. <script>
  100. import alertModal from '../../../plugins/modal'
  101. import AddEncoder from './modules/AddEncoder'
  102. import EncoderDetail from './modules/EncoderDetail'
  103. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  104. import moment from 'dayjs'
  105. import { httpAction ,getAction,postAction,putAction,deleteAction,downFile} from '@/api/manage'
  106. export default {
  107. name: "SafetyStockList",
  108. mixins: [JeecgListMixin],
  109. components: {
  110. AddEncoder,
  111. EncoderDetail
  112. },
  113. data () {
  114. return {
  115. description: '编码器列表页面',
  116. queryParam:{},
  117. selectedRowKeys:[],
  118. selectedRow:[],
  119. documentData:[],
  120. toggleSearchStatus:false,
  121. dataSource:[{}],
  122. ipagination:{
  123. current: 1,
  124. pageSize: 10,
  125. pageSizeOptions: ['10', '20', '30'],
  126. showTotal: (total, range) => {
  127. return range[0] + '-' + range[1] + ' 共' + total + '条'
  128. },
  129. showQuickJumper: true,
  130. showSizeChanger: true,
  131. total: 0
  132. },
  133. // 表头
  134. columns: [
  135. {
  136. title: '行号',
  137. dataIndex: '',
  138. key: 'rowIndex',
  139. width: 60,
  140. align: "center",
  141. customRender:function (t, r, index) {
  142. return parseInt(index)+1;
  143. }
  144. },
  145. {
  146. title: '料品名称',
  147. align:"center",
  148. dataIndex: 'inventoryName',
  149. ellipsis: true,
  150. },
  151. {
  152. title: '料品类别',
  153. align:"center",
  154. dataIndex: 'classifyName',
  155. ellipsis: true,
  156. },
  157. {
  158. title: '料品主单位',
  159. align:"center",
  160. dataIndex: 'unit',
  161. ellipsis: true,
  162. },
  163. {
  164. title: '料品单位',
  165. align:"center",
  166. dataIndex: 'auxiliaryUnit',
  167. ellipsis: true,
  168. },
  169. {
  170. title: '颜色',
  171. align:"center",
  172. dataIndex: 'color',
  173. ellipsis: true,
  174. },
  175. {
  176. title: '支长',
  177. align:"center",
  178. dataIndex: 'fixedLength',
  179. ellipsis: true,
  180. },
  181. {
  182. title: '宽/高',
  183. align:"center",
  184. dataIndex: 'widthHeight',
  185. ellipsis: true,
  186. },
  187. {
  188. title: '料品属性',
  189. align:"center",
  190. dataIndex: 'attribute',
  191. width: 200,
  192. ellipsis: true,
  193. }, {
  194. title: '是否同步',
  195. align:"center",
  196. dataIndex: 'sync',
  197. ellipsis: true,
  198. // customRender:function (t, r, index) {
  199. // if(t == '是'){
  200. // return t +"("+r.inventoryCode+")";
  201. // }else{
  202. // return t;
  203. // }
  204. // }
  205. }, {
  206. title: 'u9编码',
  207. align:"center",
  208. dataIndex: 'inventoryCode',
  209. ellipsis: true,
  210. },
  211. ],
  212. url: {
  213. list: "/encoder/encoder/list",
  214. },
  215. fileUpload: window._CONFIG['domianURL'] + "/encoder/encoder/importExcel",
  216. }
  217. },
  218. created () {
  219. this.getTableList()
  220. },
  221. computed: {
  222. },
  223. methods: {
  224. //获取数据
  225. getTableList(){
  226. alertModal.loading("执行中,请稍后!")
  227. getAction('/encoder/encoder/list',this.queryParam).then(res=>{
  228. alertModal.closeLoading();
  229. if(res.success){
  230. this.dataSource =res.result.records
  231. this.selectedRowKeys = []
  232. this.selectedRows = []
  233. this.ipagination = {
  234. total: res.result.total,
  235. current: res.result.current,
  236. pageSize: res.result.size
  237. }
  238. }else{
  239. this.$message.error(res.message);
  240. }
  241. })
  242. },
  243. onSearch(){
  244. // this.$refs.materialProcurementSearch.visible = true
  245. },
  246. //导出
  247. exportList(fileName){
  248. this.$confirm({
  249. title: '确认导出',
  250. content: '是否导出数据?',
  251. onOk: ()=> {
  252. alertModal.loading("执行中,请稍后!")
  253. let param = this.queryParam;
  254. param['selections'] = ''
  255. if(this.selectedRowKeys && this.selectedRowKeys.length>0){
  256. param['selections'] = this.selectedRowKeys.join(",")
  257. }
  258. downFile('/encoder/encoder/exportXls', param).then(data => {
  259. alertModal.closeLoading();
  260. if (!data) {
  261. this.$message.warning('文件下载失败')
  262. return
  263. }
  264. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  265. window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xlsx')
  266. } else {
  267. let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
  268. let link = document.createElement('a')
  269. link.style.display = 'none'
  270. link.href = url
  271. link.setAttribute('download', fileName + '.xlsx')
  272. document.body.appendChild(link)
  273. link.click()
  274. document.body.removeChild(link) // 下载完成移除元素
  275. window.URL.revokeObjectURL(url) // 释放掉blob对象
  276. }
  277. })
  278. }
  279. })
  280. },
  281. //重置
  282. searchReset(){
  283. this.queryParam={}
  284. this.getTableList()
  285. },
  286. //查询
  287. searchQuery(){
  288. this.queryParam.pageNo = '1'
  289. this.getTableList()
  290. },
  291. //新增
  292. addList(){
  293. this.$refs.AddEncoder.visible = true
  294. this.$refs.AddEncoder.defaultMethod='add'
  295. // this.$refs.AddEncoder.getOptionUnit()
  296. this.$refs.AddEncoder.getOptionUnitArr()
  297. },
  298. //编辑
  299. editList(){
  300. if(this.selectedRow[0].sync == '是'){
  301. this.$message.warning('已同步的数据无法修改!')
  302. return;
  303. }
  304. if(this.selectedRowKeys.length==0){
  305. this.$message.warning('请勾选数据!')
  306. }else if(this.selectedRowKeys.length>1){
  307. this.$message.warning('只可勾选一条数据')
  308. }else{
  309. this.$refs.AddEncoder.visible=true
  310. this.$refs.AddEncoder.defaultMethod='edit'
  311. this.$refs.AddEncoder.getEditData(this.selectedRowKeys[0])
  312. this.$refs.AddEncoder.getOptionUnitArr()
  313. }
  314. },
  315. handleUploadChange({ file, fileList }){
  316. if (file.status === 'done'&&file.response.success) {
  317. this.$message.success(file.response.message)
  318. this.getTableList()
  319. }else if(file.status === 'done'&&!file.response.success){
  320. this.$message.error(file.response.message)
  321. }
  322. },
  323. //同步
  324. syncList(){
  325. if(this.selectedRowKeys.length==0){
  326. this.$message.warning('请勾选数据!')
  327. }else{
  328. this.$confirm({
  329. title: '确认同步',
  330. content: '是否同步选中数据?',
  331. onOk: ()=> {
  332. var ids = this.selectedRowKeys.toString()
  333. var that = this
  334. alertModal.loading("执行中,请稍后!")
  335. deleteAction('/encoder/encoder/syncBatch', {ids: ids}).then((res) => {
  336. alertModal.closeLoading();
  337. if (res.success) {
  338. this.$message.success('同步成功!');
  339. this.getTableList()
  340. } else {
  341. this.$message.error(res.message);
  342. }
  343. });
  344. }
  345. })
  346. }
  347. },
  348. //删除
  349. delectList(){
  350. if(this.selectedRowKeys.length==0){
  351. this.$message.warning('请勾选数据!')
  352. }else if(this.selectedRowKeys.length>1){
  353. this.$confirm({
  354. title: '确认删除',
  355. content: '是否删除选中数据?',
  356. onOk: ()=> {
  357. var ids = this.selectedRowKeys.toString()
  358. var that = this
  359. alertModal.loading("执行中,请稍后!")
  360. deleteAction('/encoder/encoder/deleteBatch', {ids: ids}).then((res) => {
  361. alertModal.closeLoading();
  362. if (res.success) {
  363. this.$message.success('删除成功!');
  364. this.getTableList()
  365. } else {
  366. this.$message.error(res.message);
  367. }
  368. });
  369. }
  370. })
  371. }else{
  372. this.$confirm({
  373. title: '确认删除',
  374. content: '是否删除选中数据?',
  375. onOk: ()=> {
  376. alertModal.loading("执行中,请稍后!")
  377. deleteAction('/encoder/encoder/delete', {id: this.selectedRowKeys[0]}).then((res) => {
  378. alertModal.closeLoading();
  379. if (res.success) {
  380. this.$message.success('删除成功!');
  381. this.getTableList()
  382. } else {
  383. this.$message.error(res.message);
  384. }
  385. });
  386. }
  387. })
  388. }
  389. },
  390. //勾选
  391. onSelectChange(selectedRowKeys, selectionRows) {
  392. this.selectedRowKeys = selectedRowKeys;
  393. this.selectedRow = selectionRows;
  394. },
  395. handleTableChange(pagination, filters, sorter) {
  396. // console.log('当前页信息>>>>',pagination)
  397. this.queryParam.pageNo = pagination.current
  398. this.queryParam.pageSize = pagination.pageSize
  399. this.getTableList()
  400. },
  401. detailList(){
  402. if(this.selectedRowKeys.length==0){
  403. this.$message.warning('请选择数据!')
  404. }else if(this.selectedRowKeys.length>1){
  405. this.$message.warning('请选择一条数据!')
  406. }else{
  407. this.$refs.EncoderDetail.visible=true
  408. this.$refs.EncoderDetail.getEditData(this.selectedRowKeys[0])
  409. }
  410. },
  411. //双击
  412. clickRow(record, index){
  413. return {
  414. on: {
  415. dblclick: () => {
  416. this.$refs.EncoderDetail.visible=true
  417. this.$refs.EncoderDetail.getEditData(record.id)
  418. },
  419. }
  420. }
  421. }
  422. }
  423. }
  424. </script>
  425. <style scoped lang="less">
  426. /* @import '~@assets/less/common.less' */
  427. /deep/.ant-input{
  428. height:29px;
  429. }
  430. /deep/.ant-select-selection--single {
  431. height: 29px;
  432. }
  433. /deep/.ant-select{
  434. font-size: 12px;
  435. }
  436. /deep/.ant-form label{
  437. font-size: 12px;
  438. }
  439. /deep/.table-page-search-wrapper .ant-form-inline .ant-form-item{
  440. margin-bottom:9px
  441. }
  442. /deep/.top>.ant-card-body{
  443. padding-bottom:0px;
  444. padding-top: 12px;
  445. }
  446. /deep/.ant-btn{
  447. height:28px
  448. }
  449. /deep/.ant-table-thead > tr > th{
  450. padding: 6px 8px !important;
  451. }
  452. /deep/ .ant-table-tbody > tr > td{
  453. padding: 6px 8px !important;
  454. }
  455. /deep/ .ant-table{
  456. font-size:12px
  457. }
  458. /deep/.ant-table-fixed-header .ant-table-scroll .ant-table-header{
  459. width: calc(100% + 9px);//减去滚动条的宽度
  460. }
  461. /deep/.middle>.ant-card-body{
  462. padding-bottom:14px;
  463. padding-top:14px;
  464. }
  465. /deep/.ant-select-sm .ant-select-selection__rendered{
  466. line-height: 27px;
  467. }
  468. </style>