SbInfo.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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, y: BaseTool.Constant.scrollY}"
  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: 150,
  287. customRender: (text, record, index) => {
  288. return this.BaseTool.Object.getField(this.useTypeMap, text)
  289. }
  290. },
  291. {
  292. title: '第一维修人',
  293. dataIndex: 'repairUserName'
  294. },
  295. {
  296. title: '第二维修人',
  297. dataIndex: 'repairUserNameSecond'
  298. },
  299. {
  300. title: '使用位置',
  301. checked: true,
  302. width: 200,
  303. dataIndex: 'cph'
  304. },
  305. {
  306. title: '使用部门',
  307. checked: true,
  308. width: 200,
  309. dataIndex: 'saveUserName'
  310. },
  311. {
  312. title: '生产商',
  313. dataIndex: 'producerName',
  314. width: 120,
  315. checked: true
  316. },
  317. {
  318. title: '大小尺寸',
  319. dataIndex: 'zz',
  320. width: 120,
  321. checked: true
  322. },
  323. {
  324. title: '系列号(出厂编号)',
  325. dataIndex: 'zzh',
  326. width: 120,
  327. checked: true
  328. },
  329. {
  330. title: '是否显示',
  331. dataIndex: 'isShow',
  332. width: 120,
  333. checked: true,
  334. customRender: (text, record, index) => {
  335. return this.BaseTool.Object.getField(this.isShowMap, text)
  336. }
  337. },
  338. {
  339. title: '是否子设备',
  340. dataIndex: 'isChild',
  341. width: 120,
  342. checked: true,
  343. customRender: (text, record, index) => {
  344. return this.BaseTool.Object.getField(this.isChildMap, text)
  345. }
  346. },
  347. {
  348. title: '资产编号1',
  349. dataIndex: 'financingNo',
  350. width: 120,
  351. checked: true
  352. },
  353. {
  354. title: '设备原值',
  355. dataIndex: 'initialValue',
  356. width: 100,
  357. checked: true,
  358. customRender: (text, record, index) => {
  359. return this.BaseTool.Amount.formatter(text)
  360. }
  361. },
  362. {
  363. title: '购置日期',
  364. dataIndex: 'buyDate',
  365. width: 120,
  366. checked: true
  367. },
  368. {
  369. title: '投用日期',
  370. dataIndex: 'startDate',
  371. width: 120,
  372. checked: true
  373. },
  374. {
  375. title: '检定日期',
  376. dataIndex: 'checkDate',
  377. width: 150,
  378. checked: true
  379. },
  380. {
  381. title: '检定周期',
  382. dataIndex: 'checkPeriod',
  383. width: 100,
  384. checked: true,
  385. customRender: (text, record, index) => {
  386. if (record.nextCheckDate == null) {
  387. return '未知'
  388. } else {
  389. return text + '月'
  390. }
  391. }
  392. },
  393. {
  394. title: '检定有效期',
  395. dataIndex: 'nextCheckDate',
  396. width: 150,
  397. checked: true
  398. },
  399. {
  400. title: '检定截止',
  401. dataIndex: 'restDay',
  402. width: 100,
  403. checked: true,
  404. customRender: (text, record, index) => {
  405. if (record.nextCheckDate == null) {
  406. return '未知'
  407. } else {
  408. return this.BaseTool.Date.getCountBetween(new Date(), record.nextCheckDate, 1) + '天'
  409. }
  410. }
  411. },
  412. {
  413. title: '状态',
  414. checked: true,
  415. dataIndex: 'status',
  416. width: 100,
  417. fixed: 'right',
  418. scopedSlots: { customRender: 'status' }
  419. },
  420. {
  421. title: '操作',
  422. key: 'action',
  423. checked: true,
  424. fixed: 'right',
  425. align: 'center',
  426. width: '200',
  427. scopedSlots: { customRender: 'action' }
  428. }
  429. ],
  430. // 加载数据方法 必须为 Promise 对象
  431. loadData: parameter => {
  432. parameter = {
  433. ...parameter,
  434. ...this.queryParam,
  435. dataScope: {
  436. sortBy: 'asc',
  437. sortName: 'no'
  438. }
  439. }
  440. return getSbInfoPage(Object.assign(parameter, this.queryParam))
  441. .then(res => {
  442. return res.data
  443. })
  444. },
  445. selectedRowKeys: [],
  446. selectedRows: [],
  447. options: {
  448. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  449. rowSelection: {
  450. selectedRowKeys: this.selectedRowKeys,
  451. onChange: this.onSelectChange
  452. }
  453. },
  454. optionAlertShow: false
  455. }
  456. },
  457. created () {
  458. this.tableOption()
  459. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  460. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  461. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  462. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  463. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  464. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  465. this.isChildMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_CHILD)
  466. this.isShowMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_SHOW)
  467. },
  468. methods: {
  469. tableOption () {
  470. this.setTree()
  471. if (!this.optionAlertShow) {
  472. this.options = {
  473. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  474. rowSelection: {
  475. selectedRowKeys: this.selectedRowKeys,
  476. onChange: this.onSelectChange,
  477. getCheckboxProps: record => ({
  478. props: {
  479. disabled: false,
  480. name: record.id
  481. }
  482. })
  483. }
  484. }
  485. this.optionAlertShow = true
  486. } else {
  487. this.options = {
  488. alert: false,
  489. rowSelection: null
  490. }
  491. this.optionAlertShow = false
  492. }
  493. },
  494. batchDelete (id) {
  495. let ids = []
  496. if (this.BaseTool.String.isBlank(id)) {
  497. const length = this.selectedRows.length
  498. if (length === 0) {
  499. this.$message.info('请选择要删除的记录')
  500. return
  501. }
  502. ids = this.selectedRows.map(item => item.id)
  503. } else {
  504. ids = [id]
  505. }
  506. deleteSbInfos(ids).then(res => {
  507. this.$message.info('删除成功')
  508. this.handleOk()
  509. this.$refs.table.clearSelected()
  510. })
  511. },
  512. batchGenerate () {
  513. this.confirmLoading = true
  514. this.$message.info('正在生成请稍后')
  515. generateSbCodeAll().then(res => {
  516. this.confirmLoading = false
  517. this.$message.info('生成成功')
  518. this.handleOk()
  519. this.$refs.table.clearSelected()
  520. })
  521. },
  522. handleEdit (record) {
  523. fetchSbInfo({ id: record.id }).then(res => {
  524. this.visible = false
  525. const modal = this.$refs.baseModal
  526. modal.base(res.data)
  527. })
  528. },
  529. handlePrint (record) {
  530. this.visible = false
  531. fetchSbInfo({ id: record.id }).then(res => {
  532. const modal = this.$refs.printInSbInfoBatch
  533. modal.base([res.data])
  534. })
  535. },
  536. handlePrintBatch () {
  537. this.visible = false
  538. let ids = []
  539. const length = this.selectedRows.length
  540. if (length === 0) {
  541. this.$message.info('请选择要打印的记录')
  542. return
  543. }
  544. ids = this.selectedRows.map(item => item.id)
  545. fetchSbInfos(ids).then(res => {
  546. const modal = this.$refs.printInSbInfoBatch
  547. modal.base(res.data)
  548. })
  549. },
  550. handleStart (record) {
  551. record.status = 2
  552. updateSbInfo(record).then(res => {
  553. this.$message.info('已启用')
  554. })
  555. },
  556. handleStop (record) {
  557. record.status = 7
  558. updateSbInfo(record).then(res => {
  559. this.$message.info('已停用')
  560. })
  561. },
  562. handleAdd () {
  563. this.visible = false
  564. this.$refs.baseModal.base()
  565. },
  566. handleView (record) {
  567. fetchSbInfo({ id: record.id }).then(res => {
  568. this.visible = false
  569. const modal = this.$refs.detailModal
  570. modal.base(res.data)
  571. })
  572. },
  573. handleCopy (record) {
  574. this.visible = false
  575. fetchSbInfo({ id: record.id }).then(res => {
  576. const modal = this.$refs.baseModal
  577. modal.base(res.data, 1)
  578. })
  579. },
  580. handleOk () {
  581. this.visible = true
  582. this.setTree()
  583. this.$refs.table.refresh()
  584. },
  585. onSelectChange (selectedRowKeys, selectedRows) {
  586. this.selectedRowKeys = selectedRowKeys
  587. this.selectedRows = selectedRows
  588. },
  589. resetSearchForm () {
  590. this.queryParam = {
  591. filter: this.filter,
  592. useType: this.useType
  593. }
  594. this.visible = true
  595. this.$refs.table.refresh(true)
  596. },
  597. doExport () {
  598. const parameter = {
  599. ...this.queryParam,
  600. dataScope: {
  601. sortBy: 'asc',
  602. sortName: 'no'
  603. }
  604. }
  605. exportSbInfo(parameter).then(file => {
  606. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  607. })
  608. },
  609. setTree (record = {}) {
  610. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.JITUAN }).then(res => {
  611. this.areaList = res.data
  612. })
  613. fetchSbTypeTree().then(res => {
  614. this.treeData = res.data
  615. })
  616. },
  617. onSelect: function (selectedKeys, info) {
  618. this.selectedKeys = selectedKeys
  619. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  620. this.$refs.table.refresh(true)
  621. },
  622. onExpand (expandedKeys) {
  623. this.expandedKeys = expandedKeys
  624. this.autoExpandParent = false
  625. },
  626. handleRepairFilePreview (record) {
  627. console.log(record, 87878)
  628. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE)
  629. },
  630. handleRepairFileDownload (record) {
  631. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE, getDownloadUrl(record.id))
  632. },
  633. handleUseFilePreview (record) {
  634. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE)
  635. },
  636. handleUseFileDownload (record) {
  637. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE, getDownloadUrl(record.id))
  638. },
  639. handleCheckFilePreview (record) {
  640. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE)
  641. },
  642. handleCheckFileDownload (record) {
  643. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE, getDownloadUrl(record.id))
  644. },
  645. doImport () {
  646. this.$refs.importModal.base(null, null)
  647. },
  648. doImportForUpdate () {
  649. this.$refs.importModalUpdate.base(null, null)
  650. }
  651. }
  652. }
  653. </script>