SbScrapForm.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <a-card :bordered="false">
  3. <div v-show="visible">
  4. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  5. <a-form layout="inline">
  6. <a-row :gutter="48" v-show="advanced">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model="queryParam.keyword" placeholder="请输入名称/类型名称" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="设备Id">
  14. <a-input v-model="queryParam.sbInfoName" placeholder="设备Id" />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="状态">
  19. <a-select
  20. v-model="queryParam.status"
  21. placeholder="请选择">
  22. <a-select-option
  23. v-for="(label,value) in statusMap"
  24. :key="value"
  25. :label="label"
  26. :value="parseInt(value)">{{ label }}
  27. </a-select-option>
  28. </a-select>
  29. </a-form-item>
  30. </a-col>
  31. </a-row>
  32. <a-row :gutter="48">
  33. <a-col :md="24 || 24" :sm="24" style="text-align: right">
  34. <span class="table-page-search-submitButtons">
  35. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  36. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  37. <a @click="()=>{ this.advanced = !this.advanced}" style="margin-left: 8px">
  38. {{ advanced ? '收起' : '展开' }}
  39. <a-icon :type="advanced ? 'up' : 'down'" />
  40. </a>
  41. </span>
  42. </a-col>
  43. </a-row>
  44. </a-form>
  45. </div>
  46. <div class="table-operator" style="margin-bottom: 8px;">
  47. <a-row>
  48. <a-col :md="16">
  49. <a-button v-if="$auth('sb-scraps-add')" type="primary" icon="plus" @click="handleAdd()">新增</a-button>
  50. <a-button
  51. style="margin-left: 8px"
  52. v-if="$auth('sb-scraps-export')"
  53. type="primary"
  54. icon="download"
  55. @click="doExport">导出
  56. </a-button>
  57. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-scraps-del')">
  58. <a-menu slot="overlay">
  59. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  60. <a-menu-item key="1">
  61. <a-icon type="delete" />
  62. <a>删除</a></a-menu-item>
  63. </a-popconfirm>
  64. </a-menu>
  65. <a-button style="margin-left: 8px">
  66. 批量操作
  67. <a-icon type="down" />
  68. </a-button>
  69. </a-dropdown>
  70. </a-col>
  71. </a-row>
  72. </div>
  73. <s-table
  74. ref="table"
  75. size="default"
  76. rowKey="id"
  77. :columns="columns"
  78. :data="loadData"
  79. :alert="options.alert"
  80. :rowSelection="options.rowSelection"
  81. showPagination="auto"
  82. >
  83. <span slot="action" slot-scope="record">
  84. <template>
  85. <a @click="handleView(record)">查看</a>
  86. <operation-button
  87. v-if="$auth('sb-scraps-edit') && record.status != 3"
  88. @click="handleEdit(record)"
  89. >修改</operation-button>
  90. <operation-button
  91. v-if="$auth('sb-scraps-del') && record.status == 1"
  92. :type="2"
  93. title="是否要删除该条数据?"
  94. @confirm="batchDelete(record.id)">删除</operation-button>
  95. <operation-button
  96. v-if="record.status == 1"
  97. :type="2"
  98. title="确认提交该条数据?"
  99. @confirm="handleStart(record)">提交</operation-button>
  100. <operation-button
  101. v-if="record.status == 4"
  102. :type="2"
  103. title="再次提交该条数据?"
  104. @confirm="handleStart(record)">再次提交</operation-button>
  105. <operation-button
  106. :type="2"
  107. title="是否要终止审批?"
  108. @confirm="handleStop(record)">终止审批</operation-button>
  109. </template>
  110. </span>
  111. </s-table>
  112. </div>
  113. <base-form ref="baseModal" @ok="handleOk" />
  114. <detail ref="detailModal" @ok="handleOk" />
  115. <image-modal ref="imageModal"/>
  116. <history-table ref="historyModal"/>
  117. </a-card>
  118. </template>
  119. <script>
  120. import { STable, Ellipsis } from '@/components'
  121. import BaseForm from './modules/BaseForm'
  122. import Detail from './modules/Detail'
  123. import ImageModal from '@/views/activiti/ImageModal'
  124. import HistoryTable from '@/views/activiti/HistoryTable'
  125. import { getSbScrapFormPage, deleteSbScrapForms, fetchSbScrapForm, exportSbScrapForm } from '@/api/sb/scraps'
  126. import { startSbInfoScrap, stopSbInfoScrapForAudit } from '@/api/activiti/activiti-sb-scrap'
  127. export default {
  128. name: 'SbScrapFormList',
  129. components: {
  130. STable,
  131. Ellipsis,
  132. BaseForm,
  133. Detail,
  134. ImageModal,
  135. HistoryTable
  136. },
  137. data () {
  138. return {
  139. advanced: false,
  140. visible: true,
  141. // 查询参数
  142. queryParam: {},
  143. // 表头
  144. columns: [
  145. {
  146. title: '序号',
  147. dataIndex: 'index',
  148. customRender: (text, record, index) => {
  149. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  150. }
  151. },
  152. {
  153. title: '单号',
  154. dataIndex: 'no'
  155. },
  156. {
  157. title: '设备名称',
  158. dataIndex: 'sbName'
  159. },
  160. {
  161. title: '设备编号',
  162. dataIndex: 'sbNo'
  163. },
  164. {
  165. title: '报废原因',
  166. dataIndex: 'reason'
  167. },
  168. {
  169. title: '备注',
  170. dataIndex: 'remark'
  171. },
  172. {
  173. title: '状态',
  174. dataIndex: 'status',
  175. customRender: (text, record, index) => {
  176. return this.BaseTool.Table.getMapText(this.statusMap, text)
  177. }
  178. },
  179. {
  180. title: '申请人',
  181. dataIndex: 'applyUserName'
  182. },
  183. {
  184. title: '创建日期',
  185. dataIndex: 'createdTime'
  186. },
  187. {
  188. title: '操作',
  189. key: 'action',
  190. width: '200px',
  191. align: 'center',
  192. scopedSlots: { customRender: 'action' }
  193. }
  194. ],
  195. // 下拉框map
  196. statusMap: {},
  197. // 加载数据方法 必须为 Promise 对象
  198. loadData: parameter => {
  199. parameter = {
  200. ...parameter,
  201. ...this.queryParam,
  202. dataScope: {
  203. sortBy: 'desc',
  204. sortName: 'update_time'
  205. }
  206. }
  207. return getSbScrapFormPage(Object.assign(parameter, this.queryParam))
  208. .then(res => {
  209. return res.data
  210. })
  211. },
  212. selectedRowKeys: [],
  213. selectedRows: [],
  214. options: {
  215. alert: {
  216. show: true,
  217. clear: () => {
  218. this.selectedRowKeys = []
  219. }
  220. },
  221. rowSelection: {
  222. selectedRowKeys: this.selectedRowKeys,
  223. onChange: this.onSelectChange
  224. }
  225. },
  226. optionAlertShow: false
  227. }
  228. },
  229. created () {
  230. // 下拉框map
  231. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.ACTIVITI_FORM_STATUS)
  232. this.tableOption()
  233. },
  234. methods: {
  235. tableOption () {
  236. if (!this.optionAlertShow) {
  237. this.options = {
  238. alert: {
  239. show: true,
  240. clear: () => {
  241. this.selectedRowKeys = []
  242. }
  243. },
  244. rowSelection: {
  245. selectedRowKeys: this.selectedRowKeys,
  246. onChange: this.onSelectChange,
  247. getCheckboxProps: record => ({
  248. props: {
  249. disabled: false,
  250. name: record.id
  251. }
  252. })
  253. }
  254. }
  255. this.optionAlertShow = true
  256. } else {
  257. this.options = {
  258. alert: false,
  259. rowSelection: null
  260. }
  261. this.optionAlertShow = false
  262. }
  263. },
  264. batchDelete (id) {
  265. let ids = []
  266. if (this.BaseTool.String.isBlank(id)) {
  267. const length = this.selectedRows.length
  268. if (length === 0) {
  269. this.$message.info('请选择要删除的记录')
  270. return
  271. }
  272. ids = this.selectedRows.map(item => item.id)
  273. } else {
  274. ids = [id]
  275. }
  276. deleteSbScrapForms(ids).then(res => {
  277. this.$message.info('删除成功')
  278. this.handleOk()
  279. this.$refs.table.clearSelected()
  280. })
  281. },
  282. handleAdd () {
  283. this.visible = false
  284. const modal = this.$refs.baseModal
  285. modal.base()
  286. },
  287. handleEdit (record) {
  288. this.visible = false
  289. fetchSbScrapForm({ id: record.id }).then(res => {
  290. const modal = this.$refs.baseModal
  291. modal.base(res.data)
  292. })
  293. },
  294. handleView (record) {
  295. this.visible = false
  296. fetchSbScrapForm({ id: record.id }).then(res => {
  297. const modal = this.$refs.detailModal
  298. modal.base(res.data)
  299. })
  300. },
  301. handleOk (values) {
  302. this.visible = true
  303. this.$refs.table.refresh()
  304. },
  305. onSelectChange (selectedRowKeys, selectedRows) {
  306. this.selectedRowKeys = selectedRowKeys
  307. this.selectedRows = selectedRows
  308. },
  309. resetSearchForm () {
  310. this.queryParam = {}
  311. this.$refs.table.refresh(true)
  312. },
  313. doExport () {
  314. const parameter = {
  315. ...this.queryParam
  316. }
  317. exportSbScrapForm(parameter).then(file => {
  318. this.BaseTool.Util.downLoadExportExcel(file)
  319. })
  320. },
  321. handleStart (record) {
  322. startSbInfoScrap({ id: record.id, processInstanceId: record.processInstanceId }).then(res => {
  323. this.$message.info(res.data)
  324. this.handleEnter()
  325. })
  326. },
  327. handleViewImage (record) {
  328. const modal = this.$refs.imageModal
  329. modal.base(record.processInstanceId)
  330. },
  331. handleViewHistory (record) {
  332. const modal = this.$refs.historyModal
  333. modal.base(record)
  334. },
  335. handleStop (record) {
  336. this.$message.info('正在终止审批流程,请勿重复点击')
  337. this.confirmLoading = true
  338. stopSbInfoScrapForAudit({ id: record.id, processInstanceId: record.processInstanceId })
  339. .then(() => {
  340. this.$message.info('已成功终止审批流程,可以重新发起审批')
  341. this.confirmLoading = false
  342. this.handleOk()
  343. }).catch(() => {
  344. this.confirmLoading = false
  345. })
  346. },
  347. handleEnter () {
  348. this.$refs.table.refresh(true)
  349. },
  350. sbIdhandleDetail () {
  351. const text = this.$router.resolve({
  352. name: 'sbInfo',
  353. query: { id: this.model.sbId }
  354. })
  355. // 打开一个新的页面
  356. window.open(text.href, '_blank')
  357. }
  358. }
  359. }
  360. </script>