SpecialSbInfo.vue 17 KB

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