SbInfoPosition.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="关键字">
  8. <a-input v-model="queryParam.keyword" placeholder="请输入名称/编码"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8" :sm="24">
  12. <a-form-item label="上层设备类型">
  13. <a-tree-select
  14. style="width: 100%"
  15. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  16. :treeData="treeData"
  17. :treeNodeFilterProp="'title'"
  18. :showSearch="true"
  19. v-model="queryParam.parentId"
  20. placeholder="请选择"
  21. >
  22. </a-tree-select>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="8 || 24" :sm="24">
  26. <span class="table-page-search-submitButtons">
  27. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  28. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  29. </span>
  30. </a-col>
  31. </a-row>
  32. </a-form>
  33. </div>
  34. <div class="table-operator">
  35. <a-button v-if="$auth('sb-infos-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  36. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  37. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-infos-del')">
  38. <a-menu slot="overlay">
  39. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  40. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  41. </a-popconfirm>
  42. </a-menu>
  43. <a-button style="margin-left: 8px">
  44. 批量操作 <a-icon type="down" />
  45. </a-button>
  46. </a-dropdown>
  47. </div>
  48. <s-table
  49. ref="table"
  50. size="default"
  51. rowKey="id"
  52. :widthSpace="true"
  53. :columns="columns"
  54. :data="loadData"
  55. :alert="options.alert"
  56. :rowSelection="options.rowSelection"
  57. :scroll="{y: BaseTool.Constant.scrollY }"
  58. showPagination="auto"
  59. >
  60. <span slot="action" slot-scope="record">
  61. <template>
  62. <a @click="handleView(record)">查看</a>
  63. <a-divider type="vertical" />
  64. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  65. <a-divider type="vertical" />
  66. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  67. <a>删除</a>
  68. </a-popconfirm>
  69. <a-divider type="vertical" />
  70. <a @click="handleCopy(record)">复制</a>
  71. </template>
  72. </span>
  73. <span slot="status" slot-scope="text">
  74. <badge
  75. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  76. :text="statusMap[text]" />
  77. </span>
  78. <span slot="wbFile" slot-scope="record">
  79. <template>
  80. <a @click="handleRepairFilePreview(record)">预览</a>
  81. <a-divider type="vertical" />
  82. <a @click="handleRepairFileDownload(record)">下载</a>
  83. </template>
  84. </span>
  85. <span slot="useFile" slot-scope="record">
  86. <template>
  87. <a @click="handleUseFilePreview(record)">预览</a>
  88. <a-divider type="vertical" />
  89. <a @click="handleUseFileDownload(record)">下载</a>
  90. </template>
  91. </span>
  92. <span slot="checkFile" slot-scope="record">
  93. <template>
  94. <a @click="handleCheckFilePreview(record)">预览</a>
  95. <a-divider type="vertical" />
  96. <a @click="handleCheckFileDownload(record)">下载</a>
  97. </template>
  98. </span>
  99. </s-table>
  100. <base-form ref="baseModal" @ok="handleOk"/>
  101. <detail ref="detailModal"/>
  102. <download-modal ref="downloadModal"/>
  103. <preview-modal ref="previewModal"/>
  104. </a-card>
  105. </template>
  106. <script>
  107. import { STable, Ellipsis } from '@/components'
  108. import BaseForm from './BaseForm'
  109. import Detail from './Detail'
  110. import DownloadModal from '@/views/download/DownloadModal'
  111. import PreviewModal from '@/views/preview/PreviewModal'
  112. import { getPartInfoPositionPage, deleteSbInfos, fetchSbInfo, exportSbInfo, getSbInfoTree } from '@/api/sb/info'
  113. export default {
  114. name: 'SbInfoList',
  115. components: {
  116. STable,
  117. Ellipsis,
  118. BaseForm,
  119. Detail,
  120. DownloadModal,
  121. PreviewModal
  122. },
  123. props: {
  124. type: {
  125. type: Number,
  126. default: 1
  127. },
  128. tableParams: {
  129. type: Object,
  130. default: () => ({})
  131. },
  132. modelParams: {
  133. type: Object,
  134. default: () => ({})
  135. }
  136. },
  137. watch: {
  138. tableParams: {
  139. // deep: true, // 深度监听
  140. handler (newVal, oldVal) {
  141. if (newVal.sbId !== oldVal.sbId || newVal.positionId !== oldVal.positionId) {
  142. this.handleOk()
  143. }
  144. }
  145. }
  146. },
  147. data () {
  148. return {
  149. // 查询参数
  150. queryParam: {
  151. },
  152. depreciationTypeMap: {},
  153. levelMap: {},
  154. statusMap: {},
  155. unitMap: {},
  156. sourceTypeMap: {},
  157. treeData: [],
  158. // 表头
  159. columns: [
  160. {
  161. title: '序号',
  162. dataIndex: 'index',
  163. width: 80,
  164. checked: true,
  165. customRender: (text, record, index) => {
  166. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  167. }
  168. },
  169. {
  170. title: '设备编号',
  171. dataIndex: 'no',
  172. checked: true,
  173. width: 150
  174. },
  175. {
  176. title: '财务编码',
  177. dataIndex: 'financingNo',
  178. width: 150
  179. },
  180. {
  181. title: '设备名称',
  182. checked: true,
  183. dataIndex: 'name'
  184. },
  185. {
  186. title: '设备类型',
  187. // checked: true,
  188. dataIndex: 'type',
  189. width: 150,
  190. customRender: (text, record, index) => {
  191. return record.typeName
  192. }
  193. },
  194. {
  195. title: '设备等级',
  196. // checked: true,
  197. dataIndex: 'level',
  198. width: 150,
  199. customRender: (text, record, index) => {
  200. return this.BaseTool.Object.getField(this.levelMap, text)
  201. }
  202. },
  203. {
  204. title: '设备原值',
  205. dataIndex: 'initialValue',
  206. width: 150,
  207. customRender: (text, record, index) => {
  208. return this.BaseTool.Amount.formatter(text)
  209. }
  210. },
  211. {
  212. title: '当前价值',
  213. dataIndex: 'currentValue',
  214. width: 200,
  215. customRender: (text, record, index) => {
  216. return this.BaseTool.Amount.formatter(text)
  217. }
  218. },
  219. {
  220. title: '已折旧价值',
  221. dataIndex: 'cutValue',
  222. width: 200,
  223. customRender: (text, record, index) => {
  224. return this.BaseTool.Amount.formatter(text)
  225. }
  226. },
  227. {
  228. title: '生产商',
  229. dataIndex: 'producerId',
  230. width: 200,
  231. customRender: (text, record, index) => {
  232. return record.producerName
  233. }
  234. },
  235. {
  236. title: '设备来源方式',
  237. dataIndex: 'sourceType',
  238. width: 200,
  239. customRender: (text, record, index) => {
  240. return this.BaseTool.Object.getField(this.sourceTypeMap, text)
  241. }
  242. },
  243. {
  244. title: '来源设备id',
  245. dataIndex: 'sourceSbId',
  246. width: 200,
  247. customRender: (text, record, index) => {
  248. return record.sourceSbName
  249. }
  250. },
  251. {
  252. title: '上级设备',
  253. dataIndex: 'parentId',
  254. width: 200,
  255. customRender: (text, record, index) => {
  256. return record.parentName
  257. }
  258. },
  259. {
  260. title: '单位',
  261. dataIndex: 'unit',
  262. width: 200,
  263. customRender: (text, record, index) => {
  264. return this.BaseTool.Object.getField(this.unitMap, text)
  265. }
  266. },
  267. {
  268. title: '所属车间',
  269. dataIndex: 'positionId',
  270. width: 200,
  271. customRender: (text, record, index) => {
  272. return record.positionName
  273. }
  274. },
  275. {
  276. title: '规格型号',
  277. dataIndex: 'guigeId',
  278. width: 200,
  279. customRender: (text, record, index) => {
  280. return record.guigeName
  281. }
  282. },
  283. {
  284. title: '保管人',
  285. dataIndex: 'saveUser',
  286. width: 200
  287. },
  288. {
  289. title: '购置日期',
  290. dataIndex: 'buyDate',
  291. width: 200
  292. },
  293. {
  294. title: '投用日期',
  295. dataIndex: 'startDate',
  296. width: 200
  297. },
  298. {
  299. title: '下次检定日期',
  300. dataIndex: 'nextCheckDate',
  301. width: 200
  302. },
  303. {
  304. title: '保修截至日期',
  305. dataIndex: 'guaranteeDate',
  306. width: 200
  307. },
  308. {
  309. title: '预计工作年限',
  310. dataIndex: 'workYear',
  311. width: 200
  312. },
  313. {
  314. title: '预计报废日期',
  315. dataIndex: 'retirementDate',
  316. width: 200
  317. },
  318. {
  319. title: '折旧方式',
  320. dataIndex: 'depreciationType',
  321. width: 200,
  322. customRender: (text, record, index) => {
  323. return this.BaseTool.Object.getField(this.depreciationTypeMap, text)
  324. }
  325. },
  326. {
  327. title: '维保手册',
  328. dataIndex: 'wbFile',
  329. width: 200,
  330. scopedSlots: { customRender: 'wbFile' }
  331. },
  332. {
  333. title: '使用手册',
  334. dataIndex: 'useFile',
  335. width: 200,
  336. scopedSlots: { customRender: 'useFile' }
  337. },
  338. {
  339. title: '验收文件',
  340. dataIndex: 'checkFile',
  341. width: 200,
  342. scopedSlots: { customRender: 'checkFile' }
  343. },
  344. // {
  345. // title: '设备图片',
  346. // dataIndex: 'sbImage',
  347. // width: 200
  348. // },
  349. // {
  350. // title: '二维码',
  351. // dataIndex: 'qrCode',
  352. // width: 200
  353. // },
  354. {
  355. title: '状态',
  356. checked: true,
  357. dataIndex: 'status',
  358. width: 80,
  359. scopedSlots: { customRender: 'status' }
  360. },
  361. {
  362. title: '备注',
  363. dataIndex: 'remark',
  364. width: 200
  365. },
  366. {
  367. title: '创建日期',
  368. dataIndex: 'createdTime',
  369. width: 200
  370. },
  371. {
  372. title: '操作',
  373. key: 'action',
  374. width: '200px',
  375. checked: true,
  376. align: 'center',
  377. // fixed: 'right',
  378. scopedSlots: { width: 200, customRender: 'action' }
  379. }
  380. ],
  381. // 加载数据方法 必须为 Promise 对象
  382. loadData: parameter => {
  383. parameter = {
  384. ...parameter,
  385. ...this.queryParam,
  386. ...this.tableParams,
  387. dataScope: {
  388. sortBy: 'desc',
  389. sortName: 'update_time'
  390. }
  391. }
  392. return getPartInfoPositionPage(Object.assign(parameter, this.queryParam))
  393. .then(res => {
  394. return res.data
  395. })
  396. },
  397. selectedRowKeys: [],
  398. selectedRows: [],
  399. options: {
  400. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  401. rowSelection: {
  402. selectedRowKeys: this.selectedRowKeys,
  403. onChange: this.onSelectChange
  404. }
  405. },
  406. optionAlertShow: false
  407. }
  408. },
  409. created () {
  410. this.tableOption()
  411. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  412. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  413. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  414. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  415. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  416. },
  417. methods: {
  418. tableOption () {
  419. this.setTree()
  420. if (!this.optionAlertShow) {
  421. this.options = {
  422. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  423. rowSelection: {
  424. selectedRowKeys: this.selectedRowKeys,
  425. onChange: this.onSelectChange,
  426. getCheckboxProps: record => ({
  427. props: {
  428. disabled: false,
  429. name: record.id
  430. }
  431. })
  432. }
  433. }
  434. this.optionAlertShow = true
  435. } else {
  436. this.options = {
  437. alert: false,
  438. rowSelection: null
  439. }
  440. this.optionAlertShow = false
  441. }
  442. },
  443. batchDelete (id) {
  444. let ids = []
  445. if (this.BaseTool.String.isBlank(id)) {
  446. const length = this.selectedRows.length
  447. if (length === 0) {
  448. this.$message.info('请选择要删除的记录')
  449. return
  450. }
  451. ids = this.selectedRows.map(item => item.id)
  452. } else {
  453. ids = [id]
  454. }
  455. deleteSbInfos(ids).then(res => {
  456. this.$message.info('删除成功')
  457. this.handleOk()
  458. this.$refs.table.clearSelected()
  459. })
  460. },
  461. handleEdit (record) {
  462. fetchSbInfo({ id: record.id }).then(res => {
  463. const modal = this.$refs.baseModal
  464. modal.base(res.data)
  465. })
  466. },
  467. handleView (record) {
  468. fetchSbInfo({ id: record.id }).then(res => {
  469. const modal = this.$refs.detailModal
  470. modal.base(res.data)
  471. })
  472. },
  473. handleCopy (record) {
  474. fetchSbInfo({ id: record.id }).then(res => {
  475. const modal = this.$refs.baseModal
  476. res.data.id = null
  477. modal.base(res.data)
  478. })
  479. },
  480. handleOk () {
  481. this.setTree()
  482. this.$refs.table.refresh()
  483. },
  484. onSelectChange (selectedRowKeys, selectedRows) {
  485. this.selectedRowKeys = selectedRowKeys
  486. this.selectedRows = selectedRows
  487. },
  488. resetSearchForm () {
  489. this.queryParam = {
  490. }
  491. this.$refs.table.refresh(true)
  492. },
  493. doExport () {
  494. const parameter = {
  495. ...this.queryParam,
  496. ...this.tableParams
  497. }
  498. exportSbInfo(parameter).then(file => {
  499. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  500. })
  501. },
  502. /**
  503. * 设置设备类型树
  504. */
  505. setTree (record = {}) {
  506. getSbInfoTree({ id: record.id }).then(res => {
  507. this.treeData = res.data
  508. })
  509. },
  510. handleRepairFilePreview (record) {
  511. console.log(record, 87878)
  512. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE)
  513. },
  514. handleRepairFileDownload (record) {
  515. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE, getDownloadUrl(record.id))
  516. },
  517. handleUseFilePreview (record) {
  518. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE)
  519. },
  520. handleUseFileDownload (record) {
  521. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE, getDownloadUrl(record.id))
  522. },
  523. handleCheckFilePreview (record) {
  524. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE)
  525. },
  526. handleCheckFileDownload (record) {
  527. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE, getDownloadUrl(record.id))
  528. }
  529. }
  530. }
  531. </script>