SbInfoStandard.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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.trim="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" style="margin-bottom: 8px;">
  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" v-if="$auth('sb-infos-export')" type="primary" icon="upload" @click="handlePrintBatch()">批量打印</a-button>
  85. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-infos-del')">
  86. <a-menu slot="overlay">
  87. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  88. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  89. </a-popconfirm>
  90. </a-menu>
  91. <a-button style="margin-left: 8px">
  92. 批量操作 <a-icon type="down" />
  93. </a-button>
  94. </a-dropdown>
  95. </div>
  96. <s-table
  97. ref="table"
  98. size="default"
  99. rowKey="id"
  100. :widthSpace="true"
  101. :columns="columns"
  102. :data="loadData"
  103. :alert="options.alert"
  104. :rowSelection="options.rowSelection"
  105. :scroll="{x: 1000}"
  106. showPagination="auto"
  107. >
  108. <span slot="action" slot-scope="record">
  109. <template>
  110. <div>
  111. <!--<a-divider type="vertical" />
  112. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该设备?" @confirm="batchDelete(record.id)">
  113. <a>删除</a>
  114. </a-popconfirm>
  115. <a-divider type="vertical" />
  116. <a @click="handleCopy(record)">复制</a>-->
  117. <a-dropdown>
  118. <a-menu slot="overlay">
  119. <a-menu-item key="0">
  120. <a @click="handleView(record)">查看</a>
  121. </a-menu-item>
  122. <a-menu-item key="1">
  123. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  124. </a-menu-item>
  125. <a-menu-item v-if="record.status != 2" key="2">
  126. <a-popconfirm title="是否要启用该设备?" @confirm="handleStart(record)">
  127. <a>启用</a>
  128. </a-popconfirm>
  129. </a-menu-item>
  130. <a-menu-item v-if="record.status != 7" key="3">
  131. <a-popconfirm title="是否要停用该设备?" @confirm="handleStop(record)">
  132. <a>停用</a>
  133. </a-popconfirm>
  134. </a-menu-item>
  135. <a-menu-item key="10">
  136. <a v-if="$auth('sb-infos-edit')" @click="handleCopy(record)">复制</a>
  137. </a-menu-item>
  138. <a-menu-item key="4">
  139. <a @click="handlePrint(record)">打印</a>
  140. </a-menu-item>
  141. </a-menu>
  142. <a-button> 操作 <a-icon type="down" /> </a-button>
  143. </a-dropdown>
  144. </div>
  145. </template>
  146. </span>
  147. <span slot="status" slot-scope="text">
  148. <badge
  149. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  150. :text="statusMap[text]" />
  151. </span>
  152. </s-table>
  153. </div>
  154. </a-col>
  155. </a-row>
  156. <base-form ref="baseModal" @ok="handleOk"/>
  157. <detail ref="detailModal" @ok="handleOk"/>
  158. <download-modal ref="downloadModal"/>
  159. <preview-modal ref="previewModal"/>
  160. <import-form-add ref="importModal" @ok="handleOk"/>
  161. <import-form-update ref="importModalUpdate" @ok="handleOk"/>
  162. <print-sb-code ref="printSbCode"/>
  163. <print-in-sb-info-batch ref="printInSbInfoBatch" @ok="handleOk"/>
  164. </a-card>
  165. </template>
  166. <script>
  167. import { STable, Ellipsis } from '@/components'
  168. import BaseForm from './modules/BaseForm'
  169. import Detail from './modules/Detail'
  170. import DownloadModal from '@/views/download/DownloadModal'
  171. import PreviewModal from '@/views/preview/PreviewModal'
  172. import { updateSbInfo, getSbInfoPageStandard, deleteSbInfos, fetchSbInfo, fetchSbInfos, exportSbInfo } from '@/api/sb/info'
  173. import { queryDept } from '@/api/upms/dept'
  174. import { fetchSbTypeTree } from '@/api/sb/type'
  175. import ImportFormAdd from './modules/ImportFormAdd'
  176. import ImportFormUpdate from './modules/ImportFormUpdate'
  177. import PrintSbCode from '@/views/sb/info/modules/PrintSbCode'
  178. import PrintInSbInfoBatch from '@/views/sb/info/modules/PrintInSbInfoBatch'
  179. export default {
  180. name: 'SbInfoList',
  181. components: {
  182. STable,
  183. Ellipsis,
  184. BaseForm,
  185. Detail,
  186. DownloadModal,
  187. PreviewModal,
  188. PrintSbCode,
  189. ImportFormAdd,
  190. ImportFormUpdate,
  191. PrintInSbInfoBatch
  192. },
  193. props: {
  194. filter: {
  195. type: Number,
  196. default: -1
  197. },
  198. useType: {
  199. type: Number,
  200. default: null
  201. }
  202. },
  203. data () {
  204. return {
  205. // 查询参数
  206. queryParam: {
  207. filter: this.filter,
  208. useType: this.useType
  209. },
  210. depreciationTypeMap: {},
  211. visible: true,
  212. levelMap: {},
  213. unitMap: {},
  214. areaList: {},
  215. companyList: {},
  216. projectList: {},
  217. isChildMap: {},
  218. isShowMap: {},
  219. deptList: {},
  220. useTypeMap: {},
  221. statusMap: {},
  222. expandedKeys: [],
  223. selectedKeys: [],
  224. sourceTypeMap: {},
  225. treeData: [],
  226. // 表头
  227. // 表头
  228. columns: [
  229. {
  230. title: '序号',
  231. dataIndex: 'index',
  232. width: 100,
  233. checked: true,
  234. customRender: (text, record, index) => {
  235. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  236. }
  237. },
  238. {
  239. title: '设备名称',
  240. checked: true,
  241. width: 200,
  242. dataIndex: 'name'
  243. },
  244. {
  245. title: '设备编号',
  246. dataIndex: 'no',
  247. width: 120,
  248. checked: true
  249. },
  250. {
  251. title: '设备自编号',
  252. dataIndex: 'zbh',
  253. width: 120,
  254. checked: true
  255. },
  256. {
  257. title: '设备类型',
  258. checked: true,
  259. dataIndex: 'type',
  260. width: 150,
  261. customRender: (text, record, index) => {
  262. return record.typeName
  263. }
  264. },
  265. {
  266. title: '维护标准数目',
  267. dataIndex: 'standardNum',
  268. fixed: 'right',
  269. width: 120,
  270. checked: true
  271. },
  272. {
  273. title: '规格型号',
  274. dataIndex: 'model',
  275. width: 120,
  276. checked: true
  277. },
  278. {
  279. title: '自定义类型',
  280. checked: true,
  281. dataIndex: 'useType',
  282. width: 150,
  283. customRender: (text, record, index) => {
  284. return this.BaseTool.Object.getField(this.useTypeMap, text)
  285. }
  286. },
  287. {
  288. title: '生产商',
  289. dataIndex: 'producerName',
  290. width: 120,
  291. checked: true
  292. },
  293. {
  294. title: '大小尺寸',
  295. dataIndex: 'zz',
  296. width: 120,
  297. checked: true
  298. },
  299. {
  300. title: '出厂编号',
  301. dataIndex: 'zzh',
  302. width: 120,
  303. checked: true
  304. },
  305. {
  306. title: '是否显示',
  307. dataIndex: 'isShow',
  308. width: 120,
  309. checked: true,
  310. customRender: (text, record, index) => {
  311. return this.BaseTool.Object.getField(this.isShowMap, text)
  312. }
  313. },
  314. {
  315. title: '是否子设备',
  316. dataIndex: 'isChild',
  317. width: 120,
  318. checked: true,
  319. customRender: (text, record, index) => {
  320. return this.BaseTool.Object.getField(this.isChildMap, text)
  321. }
  322. },
  323. {
  324. title: '资产编号1',
  325. dataIndex: 'financingNo',
  326. width: 120,
  327. checked: true
  328. },
  329. {
  330. title: '状态',
  331. checked: true,
  332. dataIndex: 'status',
  333. width: 100,
  334. fixed: 'right',
  335. scopedSlots: { customRender: 'status' }
  336. },
  337. {
  338. title: '操作',
  339. key: 'action',
  340. checked: true,
  341. fixed: 'right',
  342. align: 'center',
  343. width: '200',
  344. scopedSlots: { customRender: 'action' }
  345. }
  346. ],
  347. // 加载数据方法 必须为 Promise 对象
  348. loadData: parameter => {
  349. parameter = {
  350. ...parameter,
  351. ...this.queryParam,
  352. dataScope: {
  353. sortBy: 'desc',
  354. sortName: 'no'
  355. }
  356. }
  357. return getSbInfoPageStandard(Object.assign(parameter, this.queryParam))
  358. .then(res => {
  359. return res.data
  360. })
  361. },
  362. selectedRowKeys: [],
  363. selectedRows: [],
  364. options: {
  365. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  366. rowSelection: {
  367. selectedRowKeys: this.selectedRowKeys,
  368. onChange: this.onSelectChange
  369. }
  370. },
  371. optionAlertShow: false
  372. }
  373. },
  374. created () {
  375. this.tableOption()
  376. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  377. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  378. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  379. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  380. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  381. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  382. this.isChildMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_CHILD)
  383. this.isShowMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_SHOW)
  384. },
  385. methods: {
  386. tableOption () {
  387. this.setTree()
  388. if (!this.optionAlertShow) {
  389. this.options = {
  390. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  391. rowSelection: {
  392. selectedRowKeys: this.selectedRowKeys,
  393. onChange: this.onSelectChange,
  394. getCheckboxProps: record => ({
  395. props: {
  396. disabled: false,
  397. name: record.id
  398. }
  399. })
  400. }
  401. }
  402. this.optionAlertShow = true
  403. } else {
  404. this.options = {
  405. alert: false,
  406. rowSelection: null
  407. }
  408. this.optionAlertShow = false
  409. }
  410. },
  411. batchDelete (id) {
  412. let ids = []
  413. if (this.BaseTool.String.isBlank(id)) {
  414. const length = this.selectedRows.length
  415. if (length === 0) {
  416. this.$message.info('请选择要删除的记录')
  417. return
  418. }
  419. ids = this.selectedRows.map(item => item.id)
  420. } else {
  421. ids = [id]
  422. }
  423. deleteSbInfos(ids).then(res => {
  424. this.$message.info('删除成功')
  425. this.handleOk()
  426. this.$refs.table.clearSelected()
  427. })
  428. },
  429. handleEdit (record) {
  430. fetchSbInfo({ id: record.id }).then(res => {
  431. this.visible = false
  432. const modal = this.$refs.baseModal
  433. modal.base(res.data)
  434. })
  435. },
  436. handlePrint (record) {
  437. this.visible = false
  438. fetchSbInfo({ id: record.id }).then(res => {
  439. const modal = this.$refs.printInSbInfoBatch
  440. modal.base([res.data])
  441. })
  442. },
  443. handlePrintBatch () {
  444. this.visible = false
  445. let ids = []
  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. fetchSbInfos(ids).then(res => {
  453. const modal = this.$refs.printInSbInfoBatch
  454. modal.base(res.data)
  455. })
  456. },
  457. handleStart (record) {
  458. record.status = 2
  459. updateSbInfo(record).then(res => {
  460. this.$message.info('已启用')
  461. })
  462. },
  463. handleStop (record) {
  464. record.status = 7
  465. updateSbInfo(record).then(res => {
  466. this.$message.info('已停用')
  467. })
  468. },
  469. handleAdd () {
  470. this.visible = false
  471. this.$refs.baseModal.base()
  472. },
  473. handleView (record) {
  474. fetchSbInfo({ id: record.id }).then(res => {
  475. this.visible = false
  476. const modal = this.$refs.detailModal
  477. modal.base(res.data)
  478. })
  479. },
  480. handleCopy (record) {
  481. this.visible = false
  482. fetchSbInfo({ id: record.id }).then(res => {
  483. const modal = this.$refs.baseModal
  484. modal.base(res.data, 1)
  485. })
  486. },
  487. handleOk () {
  488. this.visible = true
  489. this.setTree()
  490. this.$refs.table.refresh()
  491. },
  492. onSelectChange (selectedRowKeys, selectedRows) {
  493. this.selectedRowKeys = selectedRowKeys
  494. this.selectedRows = selectedRows
  495. },
  496. resetSearchForm () {
  497. this.queryParam = {
  498. filter: this.filter,
  499. useType: this.useType
  500. }
  501. this.visible = true
  502. this.$refs.table.refresh(true)
  503. },
  504. doExport () {
  505. const parameter = {
  506. ...this.queryParam
  507. }
  508. exportSbInfo(parameter).then(file => {
  509. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  510. })
  511. },
  512. setTree (record = {}) {
  513. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.JITUAN }).then(res => {
  514. this.areaList = res.data
  515. })
  516. fetchSbTypeTree().then(res => {
  517. this.treeData = res.data
  518. })
  519. },
  520. onSelect: function (selectedKeys, info) {
  521. this.selectedKeys = selectedKeys
  522. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  523. this.$refs.table.refresh(true)
  524. },
  525. onExpand (expandedKeys) {
  526. this.expandedKeys = expandedKeys
  527. this.autoExpandParent = false
  528. },
  529. handleRepairFilePreview (record) {
  530. console.log(record, 87878)
  531. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE)
  532. },
  533. handleRepairFileDownload (record) {
  534. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE, getDownloadUrl(record.id))
  535. },
  536. handleUseFilePreview (record) {
  537. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE)
  538. },
  539. handleUseFileDownload (record) {
  540. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE, getDownloadUrl(record.id))
  541. },
  542. handleCheckFilePreview (record) {
  543. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE)
  544. },
  545. handleCheckFileDownload (record) {
  546. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE, getDownloadUrl(record.id))
  547. },
  548. doImport () {
  549. this.$refs.importModal.base(null, null)
  550. },
  551. doImportForUpdate () {
  552. this.$refs.importModalUpdate.base(null, null)
  553. }
  554. }
  555. }
  556. </script>