SbInfoScrap.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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.trim="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" style="margin-bottom: 8px;">
  64. </div>
  65. <s-table
  66. ref="table"
  67. size="default"
  68. rowKey="id"
  69. :widthSpace="true"
  70. :columns="columns"
  71. :data="loadData"
  72. :alert="options.alert"
  73. :rowSelection="options.rowSelection"
  74. :scroll="{x: 1500, y: BaseTool.Constant.scrollY }"
  75. showPagination="auto"
  76. >
  77. <span slot="action" slot-scope="record">
  78. <template>
  79. <a @click="handleView(record)">查看</a>
  80. <a-divider type="vertical" />
  81. <a v-if="record.status != 3 && record.status != 4" @click="handleEdit(record)">报废</a>
  82. <a-divider type="vertical" />
  83. <a v-if="record.status == 41" @click="handleEdit(record)">再次提交</a>
  84. <a-divider type="vertical" />
  85. <a @click="handleViewImage(record)">流程图</a>
  86. <a-divider type="vertical" />
  87. <a @click="handleViewHistory(record)">审批历史</a>
  88. <a-divider type="vertical" />
  89. <a @click="handleStop(record)">终止审批</a>
  90. </template>
  91. </span>
  92. <span slot="status" slot-scope="text">
  93. <badge
  94. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  95. :text="statusMap[text]" />
  96. </span>
  97. </s-table>
  98. </div>
  99. </a-col>
  100. </a-row>
  101. <base-form ref="baseModal" @ok="handleOk"/>
  102. <detail ref="detailModal" @ok="handleOk"/>
  103. <image-modal ref="imageModal"/>
  104. <history-table ref="historyModal"/>
  105. </a-card>
  106. </template>
  107. <script>
  108. import { STable, Ellipsis } from '@/components'
  109. import BaseForm from './modules/BaseForm'
  110. import Detail from './modules/Detail'
  111. import DownloadModal from '@/views/download/DownloadModal'
  112. import PreviewModal from '@/views/preview/PreviewModal'
  113. import ImageModal from '@/views/activiti/ImageModal'
  114. import HistoryTable from '@/views/activiti/HistoryTable'
  115. import {
  116. getSbInfoPage,
  117. deleteSbInfos,
  118. exportSbInfo,
  119. startSbInfoScrap,
  120. stopSbInfoScrapForAudit
  121. } from '@/api/sb/info'
  122. import { queryDept } from '@/api/upms/dept'
  123. import { fetchSbTypeTree } from '@/api/sb/type'
  124. export default {
  125. name: 'SbInfoList',
  126. components: {
  127. STable,
  128. Ellipsis,
  129. BaseForm,
  130. Detail,
  131. DownloadModal,
  132. PreviewModal,
  133. ImageModal,
  134. HistoryTable
  135. },
  136. props: {
  137. filter: {
  138. type: Number,
  139. default: -1
  140. }
  141. },
  142. data () {
  143. return {
  144. // 查询参数
  145. queryParam: {
  146. filter: this.filter
  147. },
  148. depreciationTypeMap: {},
  149. visible: true,
  150. levelMap: {},
  151. unitMap: {},
  152. areaList: {},
  153. companyList: {},
  154. projectList: {},
  155. deptList: {},
  156. useTypeMap: {},
  157. statusMap: {},
  158. expandedKeys: [],
  159. selectedKeys: [],
  160. sourceTypeMap: {},
  161. treeData: [],
  162. // 表头
  163. columns: [
  164. {
  165. title: '序号',
  166. dataIndex: 'index',
  167. width: 100,
  168. checked: true,
  169. customRender: (text, record, index) => {
  170. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  171. }
  172. },
  173. {
  174. title: '设备名称',
  175. checked: true,
  176. width: 200,
  177. dataIndex: 'name'
  178. },
  179. {
  180. title: '设备编号',
  181. dataIndex: 'no',
  182. width: 120,
  183. checked: true
  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: 120,
  199. customRender: (text, record, index) => {
  200. return this.BaseTool.Object.getField(this.levelMap, text)
  201. }
  202. },
  203. {
  204. title: '设备原值',
  205. dataIndex: 'initialValue',
  206. width: 100,
  207. checked: true,
  208. customRender: (text, record, index) => {
  209. return this.BaseTool.Amount.formatter(text)
  210. }
  211. },
  212. {
  213. title: '购置日期',
  214. dataIndex: 'buyDate',
  215. width: 120,
  216. checked: true
  217. },
  218. {
  219. title: '投用日期',
  220. dataIndex: 'startDate',
  221. width: 120,
  222. checked: true
  223. },
  224. {
  225. title: '检定日期',
  226. dataIndex: 'checkDate',
  227. width: 150,
  228. checked: true
  229. },
  230. {
  231. title: '检定周期',
  232. dataIndex: 'checkPeriod',
  233. width: 100,
  234. checked: true,
  235. customRender: (text, record, index) => {
  236. if (record.nextCheckDate == null) {
  237. return '未知'
  238. } else {
  239. return text + '月'
  240. }
  241. }
  242. },
  243. {
  244. title: '检定有效期',
  245. dataIndex: 'nextCheckDate',
  246. width: 150,
  247. fixed: 'right',
  248. checked: true
  249. },
  250. {
  251. title: '检定截止',
  252. dataIndex: 'restDay',
  253. width: 100,
  254. fixed: 'right',
  255. checked: true,
  256. customRender: (text, record, index) => {
  257. if (record.nextCheckDate == null) {
  258. return '未知'
  259. } else {
  260. return this.BaseTool.Date.getCountBetween(new Date(), record.nextCheckDate, 1) + '天'
  261. }
  262. }
  263. },
  264. {
  265. title: '状态',
  266. checked: true,
  267. dataIndex: 'status',
  268. width: 200,
  269. fixed: 'right',
  270. scopedSlots: { customRender: 'status' }
  271. },
  272. {
  273. title: '操作',
  274. key: 'action',
  275. checked: true,
  276. fixed: 'right',
  277. align: 'center',
  278. width: '250',
  279. scopedSlots: { customRender: 'action' }
  280. }
  281. ],
  282. // 加载数据方法 必须为 Promise 对象
  283. loadData: parameter => {
  284. parameter = {
  285. ...parameter,
  286. ...this.queryParam,
  287. dataScope: {
  288. sortBy: 'desc',
  289. sortName: 'update_time'
  290. }
  291. }
  292. return getSbInfoPage(Object.assign(parameter, this.queryParam))
  293. .then(res => {
  294. return res.data
  295. })
  296. },
  297. selectedRowKeys: [],
  298. selectedRows: [],
  299. options: {
  300. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  301. rowSelection: {
  302. selectedRowKeys: this.selectedRowKeys,
  303. onChange: this.onSelectChange
  304. }
  305. },
  306. optionAlertShow: false
  307. }
  308. },
  309. created () {
  310. this.tableOption()
  311. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  312. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  313. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  314. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  315. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  316. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  317. },
  318. methods: {
  319. tableOption () {
  320. this.setTree()
  321. if (!this.optionAlertShow) {
  322. this.options = {
  323. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  324. rowSelection: {
  325. selectedRowKeys: this.selectedRowKeys,
  326. onChange: this.onSelectChange,
  327. getCheckboxProps: record => ({
  328. props: {
  329. disabled: false,
  330. name: record.id
  331. }
  332. })
  333. }
  334. }
  335. this.optionAlertShow = true
  336. } else {
  337. this.options = {
  338. alert: false,
  339. rowSelection: null
  340. }
  341. this.optionAlertShow = false
  342. }
  343. },
  344. batchDelete (id) {
  345. let ids = []
  346. if (this.BaseTool.String.isBlank(id)) {
  347. const length = this.selectedRows.length
  348. if (length === 0) {
  349. this.$message.info('请选择要删除的记录')
  350. return
  351. }
  352. ids = this.selectedRows.map(item => item.id)
  353. } else {
  354. ids = [id]
  355. }
  356. deleteSbInfos(ids).then(res => {
  357. this.$message.info('删除成功')
  358. this.handleOk()
  359. this.$refs.table.clearSelected()
  360. })
  361. },
  362. handleEdit (record) {
  363. startSbInfoScrap(record).then(res => {
  364. this.$message.info(res.data)
  365. this.handleOk()
  366. })
  367. },
  368. handleViewImage (record) {
  369. const modal = this.$refs.imageModal
  370. modal.base(record.processInstanceId)
  371. },
  372. handleViewHistory (record) {
  373. const modal = this.$refs.historyModal
  374. modal.base(record)
  375. },
  376. handleStop (record) {
  377. this.$message.info('正在终止审批流程,请勿重复点击')
  378. this.confirmLoading = true
  379. stopSbInfoScrapForAudit(record)
  380. .then(() => {
  381. this.$message.info('已成功终止审批流程,可以重新发起审批')
  382. this.confirmLoading = false
  383. this.handleOk()
  384. }).catch(() => {
  385. this.confirmLoading = false
  386. })
  387. },
  388. handleOk () {
  389. this.visible = true
  390. this.setTree()
  391. this.$refs.table.refresh()
  392. },
  393. onSelectChange (selectedRowKeys, selectedRows) {
  394. this.selectedRowKeys = selectedRowKeys
  395. this.selectedRows = selectedRows
  396. },
  397. resetSearchForm () {
  398. this.queryParam = {
  399. filter: this.filter
  400. }
  401. this.visible = true
  402. this.$refs.table.refresh(true)
  403. },
  404. doExport () {
  405. const parameter = {
  406. ...this.queryParam
  407. }
  408. exportSbInfo(parameter).then(file => {
  409. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  410. })
  411. },
  412. setTree (record = {}) {
  413. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.JITUAN }).then(res => {
  414. this.areaList = res.data
  415. })
  416. fetchSbTypeTree().then(res => {
  417. this.treeData = res.data
  418. })
  419. },
  420. onSelect: function (selectedKeys, info) {
  421. this.selectedKeys = selectedKeys
  422. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  423. this.$refs.table.refresh(true)
  424. },
  425. onExpand (expandedKeys) {
  426. this.expandedKeys = expandedKeys
  427. this.autoExpandParent = false
  428. }
  429. }
  430. }
  431. </script>