SbInfo.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <template>
  2. <a-card :bordered="false">
  3. <a-row :gutter="8" v-show="visible">
  4. <!-- <a-col :span="4">
  5. <a-tree
  6. @expand="onExpand"
  7. :expandedKeys="expandedKeys"
  8. :autoExpandParent="true"
  9. @select="onSelect"
  10. :selectedKeys="selectedKeys"
  11. :treeData="treeData"
  12. />
  13. </a-col>-->
  14. <a-col :span="24">
  15. <div>
  16. <div class="table-page-search-wrapper">
  17. <a-form layout="inline">
  18. <a-row :gutter="48">
  19. <a-col :md="6" :sm="24">
  20. <a-form-item label="关键字">
  21. <a-input v-model="queryParam.keyword" placeholder="请输入名称/设备新号"/>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="设备旧号">
  26. <a-input v-model="queryParam.zbh" placeholder="请输入设备旧号"/>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="设备类型">
  31. <a-tree-select
  32. style="width: 100%"
  33. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  34. :treeData="treeData"
  35. :treeNodeFilterProp="'title'"
  36. :showSearch="true"
  37. v-model="queryParam.typeId"
  38. placeholder="请选择"
  39. >
  40. </a-tree-select>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24">
  44. <a-form-item label="设备状态">
  45. <a-select v-model="queryParam.status" placeholder="请选择">
  46. <a-select-option
  47. v-for="(label,value) in statusMap"
  48. :key="value"
  49. :label="label"
  50. :value="parseInt(value)">{{ label }}
  51. </a-select-option>
  52. </a-select>
  53. </a-form-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-item label="主子设备">
  57. <a-select v-model="queryParam.isChild" placeholder="请选择">
  58. <a-select-option value="1">子设备</a-select-option>
  59. <a-select-option value="2">父设备</a-select-option>
  60. <a-select-option value="3">普通设备</a-select-option>
  61. </a-select>
  62. </a-form-item>
  63. </a-col>
  64. <a-col :md="6 || 24" :sm="24">
  65. <span class="table-page-search-submitButtons">
  66. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  67. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  68. </span>
  69. </a-col>
  70. </a-row>
  71. </a-form>
  72. </div>
  73. <div class="table-operator">
  74. <a-button v-if="$auth('sb-infos-add')" type="primary" icon="plus" @click="handleAdd">新增</a-button>
  75. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  76. <a-button style="margin-left:8px;" type="primary" @click="doImport">
  77. <a-icon type="upload"/>
  78. 新增导入
  79. </a-button>
  80. <a-button style="margin-left:8px;" type="primary" @click="doImportForUpdate">
  81. <a-icon type="upload"/>
  82. 修改导入
  83. </a-button>
  84. <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handlePrintBatch()">批量打印</a-button>
  85. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-generate-code-all')" :loading="confirmLoading" type="primary" @click="batchGenerate()">重新生成二维码</a-button>
  86. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-infos-del')">
  87. <a-menu slot="overlay">
  88. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  89. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  90. </a-popconfirm>
  91. </a-menu>
  92. <a-button style="margin-left: 8px">
  93. 批量操作 <a-icon type="down" />
  94. </a-button>
  95. </a-dropdown>
  96. </div>
  97. <s-table
  98. ref="table"
  99. size="default"
  100. rowKey="id"
  101. :widthSpace="true"
  102. :columns="columns"
  103. :data="loadData"
  104. :alert="options.alert"
  105. :rowSelection="options.rowSelection"
  106. :scroll="{x: 1000}"
  107. showPagination="auto"
  108. >
  109. <span slot="action" slot-scope="record">
  110. <template>
  111. <div>
  112. <!--<a-divider type="vertical" />
  113. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该设备?" @confirm="batchDelete(record.id)">
  114. <a>删除</a>
  115. </a-popconfirm>
  116. <a-divider type="vertical" />
  117. <a @click="handleCopy(record)">复制</a>-->
  118. <a-dropdown>
  119. <a-menu slot="overlay">
  120. <a-menu-item key="0">
  121. <a @click="handleView(record)">查看</a>
  122. </a-menu-item>
  123. <a-menu-item key="1">
  124. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  125. </a-menu-item>
  126. <a-menu-item v-if="record.status != 2" key="2">
  127. <a-popconfirm title="是否要启用该设备?" @confirm="handleStart(record)">
  128. <a>启用</a>
  129. </a-popconfirm>
  130. </a-menu-item>
  131. <a-menu-item v-if="record.status != 7" key="3">
  132. <a-popconfirm title="是否要停用该设备?" @confirm="handleStop(record)">
  133. <a>停用</a>
  134. </a-popconfirm>
  135. </a-menu-item>
  136. <a-menu-item key="10">
  137. <a v-if="$auth('sb-infos-edit')" @click="handleCopy(record)">复制</a>
  138. </a-menu-item>
  139. <a-menu-item key="4">
  140. <a @click="handlePrint(record)">打印</a>
  141. </a-menu-item>
  142. </a-menu>
  143. <a-button> 操作 <a-icon type="down" /> </a-button>
  144. </a-dropdown>
  145. </div>
  146. </template>
  147. </span>
  148. <span slot="status" slot-scope="text">
  149. <badge
  150. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  151. :text="statusMap[text]" />
  152. </span>
  153. </s-table>
  154. </div>
  155. </a-col>
  156. </a-row>
  157. <base-form ref="baseModal" @ok="handleOk"/>
  158. <detail ref="detailModal" @ok="handleOk"/>
  159. <download-modal ref="downloadModal"/>
  160. <preview-modal ref="previewModal"/>
  161. <import-form-add ref="importModal" @ok="handleOk"/>
  162. <import-form-update ref="importModalUpdate" @ok="handleOk"/>
  163. <print-sb-code ref="printSbCode"/>
  164. <print-in-sb-info-batch ref="printInSbInfoBatch" @ok="handleOk"/>
  165. </a-card>
  166. </template>
  167. <script>
  168. import { STable, Ellipsis } from '@/components'
  169. import BaseForm from './modules/BaseForm'
  170. import Detail from './modules/Detail'
  171. import DownloadModal from '@/views/download/DownloadModal'
  172. import PreviewModal from '@/views/preview/PreviewModal'
  173. import { updateSbInfo, getSbInfoPage, deleteSbInfos, fetchSbInfo, fetchSbInfos, exportSbInfo } from '@/api/sb/info'
  174. import { queryDept } from '@/api/upms/dept'
  175. import { generateSbCodeAll } from '@/api/upms/code'
  176. import { fetchSbTypeTree } from '@/api/sb/type'
  177. import ImportFormAdd from './modules/ImportFormAdd'
  178. import ImportFormUpdate from './modules/ImportFormUpdate'
  179. import PrintSbCode from '@/views/sb/info/modules/PrintSbCode'
  180. import PrintInSbInfoBatch from '@/views/sb/info/modules/PrintInSbInfoBatch'
  181. export default {
  182. name: 'SbInfoList',
  183. components: {
  184. STable,
  185. Ellipsis,
  186. BaseForm,
  187. Detail,
  188. DownloadModal,
  189. PreviewModal,
  190. PrintSbCode,
  191. ImportFormAdd,
  192. ImportFormUpdate,
  193. PrintInSbInfoBatch
  194. },
  195. props: {
  196. filter: {
  197. type: Number,
  198. default: -1
  199. },
  200. useType: {
  201. type: Number,
  202. default: null
  203. }
  204. },
  205. data () {
  206. return {
  207. // 查询参数
  208. queryParam: {
  209. filter: this.filter,
  210. useType: this.useType
  211. },
  212. depreciationTypeMap: {},
  213. visible: true,
  214. levelMap: {},
  215. unitMap: {},
  216. areaList: {},
  217. companyList: {},
  218. projectList: {},
  219. isChildMap: {},
  220. isShowMap: {},
  221. deptList: {},
  222. confirmLoading: false,
  223. useTypeMap: {},
  224. statusMap: {},
  225. expandedKeys: [],
  226. selectedKeys: [],
  227. sourceTypeMap: {},
  228. treeData: [],
  229. // 表头
  230. columns: [
  231. {
  232. title: '序号',
  233. dataIndex: 'index',
  234. width: 100,
  235. checked: true,
  236. customRender: (text, record, index) => {
  237. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  238. }
  239. },
  240. {
  241. title: '设备编号',
  242. dataIndex: 'no',
  243. width: 120,
  244. checked: true
  245. },
  246. {
  247. title: '设备名称',
  248. checked: true,
  249. width: 200,
  250. dataIndex: 'name'
  251. },
  252. {
  253. title: '设备旧号',
  254. dataIndex: 'zbh',
  255. width: 120,
  256. checked: true
  257. },
  258. {
  259. title: '设备类型',
  260. checked: true,
  261. dataIndex: 'type',
  262. width: 150,
  263. customRender: (text, record, index) => {
  264. return record.typeName
  265. }
  266. },
  267. {
  268. title: '设备等级',
  269. checked: true,
  270. dataIndex: 'level',
  271. width: 120,
  272. customRender: (text, record, index) => {
  273. return this.BaseTool.Object.getField(this.levelMap, text)
  274. }
  275. },
  276. {
  277. title: '规格型号',
  278. dataIndex: 'model',
  279. width: 120,
  280. checked: true
  281. },
  282. {
  283. title: '自定义类型',
  284. checked: true,
  285. dataIndex: 'useType',
  286. width: 120,
  287. customRender: (text, record, index) => {
  288. return this.BaseTool.Object.getField(this.useTypeMap, text)
  289. }
  290. },
  291. {
  292. title: '生产商',
  293. dataIndex: 'producerName',
  294. width: 120,
  295. checked: true
  296. },
  297. {
  298. title: '大小尺寸',
  299. dataIndex: 'zz',
  300. width: 120,
  301. checked: true
  302. },
  303. {
  304. title: '系列号(出厂编号)',
  305. dataIndex: 'zzh',
  306. width: 120,
  307. checked: true
  308. },
  309. {
  310. title: '是否显示',
  311. dataIndex: 'isShow',
  312. width: 120,
  313. checked: true,
  314. customRender: (text, record, index) => {
  315. return this.BaseTool.Object.getField(this.isShowMap, text)
  316. }
  317. },
  318. {
  319. title: '是否子设备',
  320. dataIndex: 'isChild',
  321. width: 120,
  322. checked: true,
  323. customRender: (text, record, index) => {
  324. return this.BaseTool.Object.getField(this.isChildMap, text)
  325. }
  326. },
  327. {
  328. title: '资产编号1',
  329. dataIndex: 'financingNo',
  330. width: 120,
  331. checked: true
  332. },
  333. {
  334. title: '设备原值',
  335. dataIndex: 'initialValue',
  336. width: 100,
  337. checked: true,
  338. customRender: (text, record, index) => {
  339. return this.BaseTool.Amount.formatter(text)
  340. }
  341. },
  342. {
  343. title: '购置日期',
  344. dataIndex: 'buyDate',
  345. width: 120,
  346. checked: true
  347. },
  348. {
  349. title: '投用日期',
  350. dataIndex: 'startDate',
  351. width: 120,
  352. checked: true
  353. },
  354. {
  355. title: '检定日期',
  356. dataIndex: 'checkDate',
  357. width: 150,
  358. checked: true
  359. },
  360. {
  361. title: '检定周期',
  362. dataIndex: 'checkPeriod',
  363. width: 100,
  364. checked: true,
  365. customRender: (text, record, index) => {
  366. if (record.nextCheckDate == null) {
  367. return '未知'
  368. } else {
  369. return text + '月'
  370. }
  371. }
  372. },
  373. {
  374. title: '检定有效期',
  375. dataIndex: 'nextCheckDate',
  376. width: 150,
  377. checked: true
  378. },
  379. {
  380. title: '检定截止',
  381. dataIndex: 'restDay',
  382. width: 100,
  383. checked: true,
  384. customRender: (text, record, index) => {
  385. if (record.nextCheckDate == null) {
  386. return '未知'
  387. } else {
  388. return this.BaseTool.Date.getCountBetween(new Date(), record.nextCheckDate, 1) + '天'
  389. }
  390. }
  391. },
  392. {
  393. title: '状态',
  394. checked: true,
  395. dataIndex: 'status',
  396. width: 100,
  397. fixed: 'right',
  398. scopedSlots: { customRender: 'status' }
  399. },
  400. {
  401. title: '操作',
  402. key: 'action',
  403. checked: true,
  404. fixed: 'right',
  405. align: 'center',
  406. width: '200',
  407. scopedSlots: { customRender: 'action' }
  408. }
  409. ],
  410. // 加载数据方法 必须为 Promise 对象
  411. loadData: parameter => {
  412. parameter = {
  413. ...parameter,
  414. ...this.queryParam,
  415. dataScope: {
  416. sortBy: 'desc',
  417. sortName: 'no'
  418. }
  419. }
  420. return getSbInfoPage(Object.assign(parameter, this.queryParam))
  421. .then(res => {
  422. return res.data
  423. })
  424. },
  425. selectedRowKeys: [],
  426. selectedRows: [],
  427. options: {
  428. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  429. rowSelection: {
  430. selectedRowKeys: this.selectedRowKeys,
  431. onChange: this.onSelectChange
  432. }
  433. },
  434. optionAlertShow: false
  435. }
  436. },
  437. created () {
  438. this.tableOption()
  439. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  440. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  441. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  442. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  443. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  444. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  445. this.isChildMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_CHILD)
  446. this.isShowMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_SHOW)
  447. },
  448. methods: {
  449. tableOption () {
  450. this.setTree()
  451. if (!this.optionAlertShow) {
  452. this.options = {
  453. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  454. rowSelection: {
  455. selectedRowKeys: this.selectedRowKeys,
  456. onChange: this.onSelectChange,
  457. getCheckboxProps: record => ({
  458. props: {
  459. disabled: false,
  460. name: record.id
  461. }
  462. })
  463. }
  464. }
  465. this.optionAlertShow = true
  466. } else {
  467. this.options = {
  468. alert: false,
  469. rowSelection: null
  470. }
  471. this.optionAlertShow = false
  472. }
  473. },
  474. batchDelete (id) {
  475. let ids = []
  476. if (this.BaseTool.String.isBlank(id)) {
  477. const length = this.selectedRows.length
  478. if (length === 0) {
  479. this.$message.info('请选择要删除的记录')
  480. return
  481. }
  482. ids = this.selectedRows.map(item => item.id)
  483. } else {
  484. ids = [id]
  485. }
  486. deleteSbInfos(ids).then(res => {
  487. this.$message.info('删除成功')
  488. this.handleOk()
  489. this.$refs.table.clearSelected()
  490. })
  491. },
  492. batchGenerate () {
  493. this.confirmLoading = true
  494. this.$message.info('正在生成请稍后')
  495. generateSbCodeAll().then(res => {
  496. this.confirmLoading = false
  497. this.$message.info('生成成功')
  498. this.handleOk()
  499. this.$refs.table.clearSelected()
  500. })
  501. },
  502. handleEdit (record) {
  503. fetchSbInfo({ id: record.id }).then(res => {
  504. this.visible = false
  505. const modal = this.$refs.baseModal
  506. modal.base(res.data)
  507. })
  508. },
  509. handlePrint (record) {
  510. this.visible = false
  511. fetchSbInfo({ id: record.id }).then(res => {
  512. const modal = this.$refs.printInSbInfoBatch
  513. modal.base([res.data])
  514. })
  515. },
  516. handlePrintBatch () {
  517. this.visible = false
  518. let ids = []
  519. const length = this.selectedRows.length
  520. if (length === 0) {
  521. this.$message.info('请选择要打印的记录')
  522. return
  523. }
  524. ids = this.selectedRows.map(item => item.id)
  525. fetchSbInfos(ids).then(res => {
  526. const modal = this.$refs.printInSbInfoBatch
  527. modal.base(res.data)
  528. })
  529. },
  530. handleStart (record) {
  531. record.status = 2
  532. updateSbInfo(record).then(res => {
  533. this.$message.info('已启用')
  534. })
  535. },
  536. handleStop (record) {
  537. record.status = 7
  538. updateSbInfo(record).then(res => {
  539. this.$message.info('已停用')
  540. })
  541. },
  542. handleAdd () {
  543. this.visible = false
  544. this.$refs.baseModal.base()
  545. },
  546. handleView (record) {
  547. fetchSbInfo({ id: record.id }).then(res => {
  548. this.visible = false
  549. const modal = this.$refs.detailModal
  550. modal.base(res.data)
  551. })
  552. },
  553. handleCopy (record) {
  554. this.visible = false
  555. fetchSbInfo({ id: record.id }).then(res => {
  556. const modal = this.$refs.baseModal
  557. modal.base(res.data, 1)
  558. })
  559. },
  560. handleOk () {
  561. this.visible = true
  562. this.setTree()
  563. this.$refs.table.refresh()
  564. },
  565. onSelectChange (selectedRowKeys, selectedRows) {
  566. this.selectedRowKeys = selectedRowKeys
  567. this.selectedRows = selectedRows
  568. },
  569. resetSearchForm () {
  570. this.queryParam = {
  571. filter: this.filter,
  572. useType: this.useType
  573. }
  574. this.visible = true
  575. this.$refs.table.refresh(true)
  576. },
  577. doExport () {
  578. const parameter = {
  579. ...this.queryParam,
  580. dataScope: {
  581. sortBy: 'desc',
  582. sortName: 'no'
  583. }
  584. }
  585. exportSbInfo(parameter).then(file => {
  586. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  587. })
  588. },
  589. setTree (record = {}) {
  590. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.JITUAN }).then(res => {
  591. this.areaList = res.data
  592. })
  593. fetchSbTypeTree().then(res => {
  594. this.treeData = res.data
  595. })
  596. },
  597. onSelect: function (selectedKeys, info) {
  598. this.selectedKeys = selectedKeys
  599. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  600. this.$refs.table.refresh(true)
  601. },
  602. onExpand (expandedKeys) {
  603. this.expandedKeys = expandedKeys
  604. this.autoExpandParent = false
  605. },
  606. handleRepairFilePreview (record) {
  607. console.log(record, 87878)
  608. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE)
  609. },
  610. handleRepairFileDownload (record) {
  611. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE, getDownloadUrl(record.id))
  612. },
  613. handleUseFilePreview (record) {
  614. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE)
  615. },
  616. handleUseFileDownload (record) {
  617. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE, getDownloadUrl(record.id))
  618. },
  619. handleCheckFilePreview (record) {
  620. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE)
  621. },
  622. handleCheckFileDownload (record) {
  623. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE, getDownloadUrl(record.id))
  624. },
  625. doImport () {
  626. this.$refs.importModal.base(null, null)
  627. },
  628. doImportForUpdate () {
  629. this.$refs.importModalUpdate.base(null, null)
  630. }
  631. }
  632. }
  633. </script>