SbInfo.vue 17 KB

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