SbInfoDebug.vue 19 KB

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