ParentSbInfo.vue 18 KB

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