IdleAssets.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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">
  7. <a-col :md="8" :sm="24">
  8. <a-form-item label="闲置名称">
  9. <a-input v-model.trim="queryParam.name" placeholder="请输入闲置名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="8 || 24" :sm="24">
  13. <span class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <div class="table-operator" style="margin-bottom: 8px;">
  22. <a-button v-if="$auth('purchase-purchase-orders-add')" type="primary" icon="plus" @click="$refs.baseForm.base()">新增</a-button>
  23. <!-- <a-button v-if="$auth('purchase-purchase-orders-add')" style="margin-left: 8px" type="primary" icon="plus" @click="$refs.addSpareForm.base()">新增物料</a-button>-->
  24. <!-- <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-purchase-orders-del')">
  25. <a-menu slot="overlay">
  26. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  27. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  28. </a-popconfirm>
  29. </a-menu>
  30. <a-button style="margin-left: 8px">
  31. 批量操作 <a-icon type="down" />
  32. </a-button>
  33. </a-dropdown> -->
  34. </div>
  35. <s-table
  36. ref="table"
  37. size="default"
  38. rowKey="id"
  39. :columns="columns"
  40. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  41. :data="loadData"
  42. :alert="options.alert"
  43. :rowSelection="options.rowSelection"
  44. showPagination="auto"
  45. >
  46. <span slot="action" slot-scope="record">
  47. <a @click="handleView(record)">查看</a>
  48. <!-- <operation-button
  49. @click="handleEdit(record)"
  50. >修改</operation-button> -->
  51. <operation-button
  52. v-if="record.status===1||record.status===2"
  53. @click="handleAudit(record)"
  54. >审核</operation-button>
  55. </span>
  56. <template #status="text">
  57. <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.SB_UNUSED_STATUS[text]"/>
  58. </template>
  59. </s-table>
  60. </div>
  61. <BaseForm ref="baseForm" @ok="handleOk"/>
  62. <AuditForm ref="auditForm" @ok="handleOk"/>
  63. <Detail ref="detail" @ok="handleOk" />
  64. </a-card>
  65. </template>
  66. <script>
  67. import { STable, Ellipsis } from '@/components'
  68. import { getSbUnusedPage, getUnusedInfo } from '@/api/idle-assets/idle-assets'
  69. import BaseForm from './modules/BaseForm.vue'
  70. import AuditForm from './modules/AuditForm.vue'
  71. import Detail from './modules/Detail.vue'
  72. export default {
  73. name: 'IdleAssets',
  74. components: {
  75. STable,
  76. Ellipsis,
  77. BaseForm,
  78. AuditForm,
  79. Detail
  80. },
  81. data () {
  82. return {
  83. // 查询参数
  84. queryParam: {
  85. },
  86. visible: true,
  87. // 表头
  88. columns: [
  89. {
  90. title: '序号',
  91. dataIndex: 'index',
  92. checked: true,
  93. width: 70,
  94. customRender: (text, record, index) => {
  95. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  96. }
  97. },
  98. {
  99. title: '名称',
  100. dataIndex: 'name',
  101. checked: true,
  102. width: 100
  103. },
  104. {
  105. title: '审核人',
  106. dataIndex: 'verifyUserName',
  107. checked: true,
  108. width: 130
  109. },
  110. {
  111. title: '申请时间',
  112. dataIndex: 'createdTime',
  113. checked: true,
  114. width: 130
  115. },
  116. {
  117. title: '状态',
  118. dataIndex: 'status',
  119. width: '100px',
  120. fixed: 'right',
  121. checked: true,
  122. align: 'center',
  123. scopedSlots: { customRender: 'status' }
  124. },
  125. {
  126. title: '操作',
  127. key: 'action',
  128. width: '200px',
  129. fixed: 'right',
  130. checked: true,
  131. align: 'center',
  132. scopedSlots: { customRender: 'action' }
  133. }
  134. ],
  135. // 加载数据方法 必须为 Promise 对象
  136. loadData: parameter => {
  137. parameter = {
  138. ...parameter,
  139. ...this.queryParam,
  140. dataScope: {
  141. sortBy: 'desc',
  142. sortName: 'created_time'
  143. }
  144. }
  145. return getSbUnusedPage(Object.assign(parameter, this.queryParam))
  146. .then(res => {
  147. return res.data
  148. })
  149. },
  150. selectedRowKeys: [],
  151. selectedRows: [],
  152. options: {
  153. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  154. rowSelection: {
  155. selectedRowKeys: this.selectedRowKeys
  156. }
  157. },
  158. optionAlertShow: false,
  159. // 下拉框map
  160. statusMap: {}
  161. }
  162. },
  163. created () {
  164. // 下拉框map
  165. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_UNUSED_STATUS)
  166. this.tableOption()
  167. },
  168. methods: {
  169. tableOption () {
  170. if (!this.optionAlertShow) {
  171. this.options = {
  172. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  173. rowSelection: {
  174. selectedRowKeys: this.selectedRowKeys,
  175. getCheckboxProps: record => ({
  176. props: {
  177. disabled: false,
  178. name: record.id
  179. }
  180. })
  181. }
  182. }
  183. this.optionAlertShow = true
  184. } else {
  185. this.options = {
  186. alert: false,
  187. rowSelection: null
  188. }
  189. this.optionAlertShow = false
  190. }
  191. },
  192. handleOk () {
  193. this.visible = true
  194. this.$refs.table.refresh()
  195. },
  196. resetSearchForm () {
  197. this.queryParam = {
  198. }
  199. this.$refs.table.refresh(true)
  200. },
  201. handleEnter () {
  202. this.$refs.table.refresh(true)
  203. },
  204. handleAudit (record) {
  205. this.$refs.auditForm.base(record)
  206. },
  207. handleEdit (record) {
  208. },
  209. handleView (record) {
  210. getUnusedInfo({ id: record.id }).then(res => {
  211. this.$refs.detail.base(res.data)
  212. this.visible = false
  213. })
  214. }
  215. }
  216. }
  217. </script>