SbModel.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <a-card :bordered="false">
  3. <a-row :gutter="8">
  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 class="table-page-search-wrapper">
  16. <a-form layout="inline">
  17. <a-row :gutter="48">
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="关键字">
  20. <a-input v-model="queryParam.keyword" placeholder="请输入名称/编码"/>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="状态">
  25. <a-select v-model="queryParam.status" placeholder="请选择">
  26. <a-select-option
  27. v-for="(label,value) in statusMap"
  28. :key="value"
  29. :label="label"
  30. :value="parseInt(value)">{{ label }}
  31. </a-select-option>
  32. </a-select>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6 || 24" :sm="24">
  36. <span class="table-page-search-submitButtons">
  37. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  38. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  39. </span>
  40. </a-col>
  41. </a-row>
  42. </a-form>
  43. </div>
  44. <div class="table-operator">
  45. <a-button v-if="$auth('sb-infos-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  46. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  47. <a-button style="margin-left:8px;" type="primary" @click="doImport">
  48. <a-icon type="upload"/>
  49. 修改导入
  50. </a-button>
  51. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-infos-del')">
  52. <a-menu slot="overlay">
  53. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  54. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  55. </a-popconfirm>
  56. </a-menu>
  57. <a-button style="margin-left: 8px">
  58. 批量操作 <a-icon type="down" />
  59. </a-button>
  60. </a-dropdown>
  61. </div>
  62. <s-table
  63. ref="table"
  64. size="default"
  65. rowKey="id"
  66. :widthSpace="true"
  67. :columns="columns"
  68. :data="loadData"
  69. :alert="options.alert"
  70. :rowSelection="options.rowSelection"
  71. :scroll="{y: BaseTool.Constant.scrollY }"
  72. showPagination="auto"
  73. >
  74. <span slot="action" slot-scope="record">
  75. <template>
  76. <a @click="handleView(record)">查看</a>
  77. <a-divider type="vertical" />
  78. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  79. <a-divider type="vertical" />
  80. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  81. <a>删除</a>
  82. </a-popconfirm>
  83. <a-divider type="vertical" />
  84. <a @click="handleCopy(record)">复制</a>
  85. </template>
  86. </span>
  87. <span slot="status" slot-scope="text">
  88. <badge
  89. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  90. :text="statusMap[text]" />
  91. </span>
  92. </s-table>
  93. </a-col>
  94. </a-row>
  95. <base-form ref="baseModal" @ok="handleOk"/>
  96. <detail ref="detailModal"/>
  97. <import-form-add ref="importModal" @ok="handleOk"/>
  98. <download-modal ref="downloadModal"/>
  99. <preview-modal ref="previewModal"/>
  100. </a-card>
  101. </template>
  102. <script>
  103. import { STable, Ellipsis } from '@/components'
  104. import BaseForm from './modules/BaseForm'
  105. import Detail from './modules/Detail'
  106. import DownloadModal from '@/views/download/DownloadModal'
  107. import PreviewModal from '@/views/preview/PreviewModal'
  108. import { getSbInfoPage, deleteSbInfos, fetchSbInfo, exportSbInfo } from '@/api/sb/model'
  109. import { fetchSbTypeTree } from '@/api/sb/type'
  110. import ImportFormAdd from './modules/ImportFormAdd'
  111. export default {
  112. name: 'SbModelList',
  113. components: {
  114. STable,
  115. Ellipsis,
  116. BaseForm,
  117. Detail,
  118. DownloadModal,
  119. PreviewModal,
  120. ImportFormAdd
  121. },
  122. data () {
  123. return {
  124. // 查询参数
  125. queryParam: {
  126. },
  127. depreciationTypeMap: {},
  128. levelMap: {},
  129. statusMap: {},
  130. unitMap: {},
  131. sourceTypeMap: {},
  132. useTypeMap: {},
  133. treeData: [],
  134. expandedKeys: [],
  135. selectedKeys: [],
  136. // 表头
  137. columns: [
  138. {
  139. title: '序号',
  140. dataIndex: 'index',
  141. width: 80,
  142. checked: true,
  143. customRender: (text, record, index) => {
  144. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  145. }
  146. },
  147. {
  148. title: '设备名称',
  149. checked: true,
  150. dataIndex: 'name'
  151. },
  152. {
  153. title: '设备型号',
  154. checked: true,
  155. dataIndex: 'model'
  156. },
  157. {
  158. title: '价格',
  159. dataIndex: 'value'
  160. },
  161. {
  162. title: '单位',
  163. dataIndex: 'unit'
  164. },
  165. {
  166. title: '设备类型',
  167. checked: true,
  168. dataIndex: 'type',
  169. customRender: (text, record, index) => {
  170. return record.typeName
  171. }
  172. },
  173. {
  174. title: '设备等级',
  175. dataIndex: 'level',
  176. customRender: (text, record, index) => {
  177. return this.BaseTool.Object.getField(this.levelMap, text)
  178. }
  179. },
  180. {
  181. title: '数量',
  182. checked: true,
  183. dataIndex: 'num'
  184. },
  185. {
  186. title: '自定义类型',
  187. dataIndex: 'useType',
  188. checked: true,
  189. customRender: (text, record, index) => {
  190. return this.BaseTool.Object.getField(this.useTypeMap, text)
  191. }
  192. },
  193. {
  194. title: '生产商',
  195. dataIndex: 'producerId',
  196. customRender: (text, record, index) => {
  197. return record.producerName
  198. }
  199. },
  200. {
  201. title: '状态',
  202. checked: true,
  203. dataIndex: 'status',
  204. scopedSlots: { customRender: 'status' }
  205. },
  206. {
  207. title: '备注',
  208. dataIndex: 'remark'
  209. },
  210. {
  211. title: '创建日期',
  212. dataIndex: 'createdTime'
  213. },
  214. {
  215. title: '操作',
  216. key: 'action',
  217. checked: true,
  218. align: 'center',
  219. scopedSlots: { customRender: 'action' }
  220. }
  221. ],
  222. // 加载数据方法 必须为 Promise 对象
  223. loadData: parameter => {
  224. parameter = {
  225. ...parameter,
  226. ...this.queryParam,
  227. dataScope: {
  228. sortBy: 'desc',
  229. sortName: 'name'
  230. }
  231. }
  232. return getSbInfoPage(Object.assign(parameter, this.queryParam))
  233. .then(res => {
  234. return res.data
  235. })
  236. },
  237. selectedRowKeys: [],
  238. selectedRows: [],
  239. options: {
  240. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  241. rowSelection: {
  242. selectedRowKeys: this.selectedRowKeys,
  243. onChange: this.onSelectChange
  244. }
  245. },
  246. optionAlertShow: false
  247. }
  248. },
  249. created () {
  250. this.tableOption()
  251. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  252. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  253. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_MODEL_RECOMMEND)
  254. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  255. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  256. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  257. fetchSbTypeTree().then(res => {
  258. this.treeData = res.data
  259. })
  260. },
  261. methods: {
  262. tableOption () {
  263. if (!this.optionAlertShow) {
  264. this.options = {
  265. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  266. rowSelection: {
  267. selectedRowKeys: this.selectedRowKeys,
  268. onChange: this.onSelectChange,
  269. getCheckboxProps: record => ({
  270. props: {
  271. disabled: false,
  272. name: record.id
  273. }
  274. })
  275. }
  276. }
  277. this.optionAlertShow = true
  278. } else {
  279. this.options = {
  280. alert: false,
  281. rowSelection: null
  282. }
  283. this.optionAlertShow = false
  284. }
  285. },
  286. batchDelete (id) {
  287. let ids = []
  288. if (this.BaseTool.String.isBlank(id)) {
  289. const length = this.selectedRows.length
  290. if (length === 0) {
  291. this.$message.info('请选择要删除的记录')
  292. return
  293. }
  294. ids = this.selectedRows.map(item => item.id)
  295. } else {
  296. ids = [id]
  297. }
  298. deleteSbInfos(ids).then(res => {
  299. this.$message.info('删除成功')
  300. this.handleOk()
  301. this.$refs.table.clearSelected()
  302. })
  303. },
  304. handleEdit (record) {
  305. fetchSbInfo({ id: record.id }).then(res => {
  306. const modal = this.$refs.baseModal
  307. modal.base(res.data)
  308. })
  309. },
  310. handleView (record) {
  311. fetchSbInfo({ id: record.id }).then(res => {
  312. const modal = this.$refs.detailModal
  313. modal.base(res.data)
  314. })
  315. },
  316. handleCopy (record) {
  317. fetchSbInfo({ id: record.id }).then(res => {
  318. const modal = this.$refs.baseModal
  319. res.data.id = null
  320. modal.base(res.data)
  321. })
  322. },
  323. handleOk () {
  324. this.$refs.table.refresh()
  325. },
  326. onSelectChange (selectedRowKeys, selectedRows) {
  327. this.selectedRowKeys = selectedRowKeys
  328. this.selectedRows = selectedRows
  329. },
  330. resetSearchForm () {
  331. this.queryParam = {
  332. }
  333. this.$refs.table.refresh(true)
  334. },
  335. doExport () {
  336. const parameter = {
  337. ...this.queryParam
  338. }
  339. exportSbInfo(parameter).then(file => {
  340. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  341. })
  342. },
  343. onSelect: function (selectedKeys, info) {
  344. this.selectedKeys = selectedKeys
  345. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  346. this.$refs.table.refresh(true)
  347. },
  348. onExpand (expandedKeys) {
  349. this.expandedKeys = expandedKeys
  350. this.autoExpandParent = false
  351. },
  352. handleRepairFilePreview (record) {
  353. console.log(record, 87878)
  354. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE)
  355. },
  356. handleRepairFileDownload (record) {
  357. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_REPAIRFILE, getDownloadUrl(record.id))
  358. },
  359. handleUseFilePreview (record) {
  360. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE)
  361. },
  362. handleUseFileDownload (record) {
  363. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_USEFILE, getDownloadUrl(record.id))
  364. },
  365. handleCheckFilePreview (record) {
  366. this.$refs.previewModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE)
  367. },
  368. handleCheckFileDownload (record) {
  369. // this.$refs.downloadModal.base(record.id, this.DictCache.VALUE.FILE_MODULE.SBINFO_RECHECKFILE, getDownloadUrl(record.id))
  370. },
  371. doImport () {
  372. this.$refs.importModal.base()
  373. }
  374. }
  375. }
  376. </script>