FillProjectQuantity.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <a-card :bordered="false">
  3. <a-row :gutter="8">
  4. <a-col :span="5">
  5. <a-tree
  6. @expand="onExpand"
  7. :expandedKeys="expandedKeys"
  8. :autoExpandParent="autoExpandParent"
  9. @select="onSelect"
  10. :selectedKeys="selectedKeys"
  11. :treeData="fillProjectQuantityTree"
  12. />
  13. </a-col>
  14. <a-col :span="19">
  15. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  16. <a-form layout="inline">
  17. <a-row :gutter="48">
  18. <a-col :md="8" :sm="24">
  19. <a-form-item label="关键字">
  20. <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="8" :sm="24">
  24. <a-form-item label="部门">
  25. <a-tree-select
  26. v-model="queryParam.deptCode"
  27. :treeNodeFilterProp="'title'"
  28. placeholder="请选择部门"
  29. :allow-clear="true"
  30. :show-search="true"
  31. :replaceFields="{children:'children', title:'title', key:'key', value: 'deptCode' }"
  32. :tree-default-expand-all="true"
  33. :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  34. :treeData="treeData"
  35. />
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="8 || 24" :sm="24">
  39. <span class="table-page-search-submitButtons">
  40. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  41. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  42. </span>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <div class="table-operator" style="margin-bottom: 8px;">
  48. <a-button v-if="$auth('fill-project-quantities-add')" type="primary" icon="plus" @click="$refs.baseModal.base({}, {parentItem: selectedItem})">新增</a-button>
  49. <a-button style="margin-left: 8px" v-if="$auth('fill-project-quantities-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  50. <a-button style="margin-left: 8px" type="primary" icon="download" @click="doImport">导入</a-button>
  51. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('fill-project-quantities-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. :bordered="this.MyGlobalConstant.BORDERED"
  67. :columns="columns"
  68. :data="loadData"
  69. :alert="options.alert"
  70. :rowSelection="options.rowSelection"
  71. showPagination="auto"
  72. >
  73. <span slot="action" slot-scope="record">
  74. <template>
  75. <a @click="handleView(record)">查看</a>
  76. <operation-button
  77. v-if="$auth('fill-project-quantities-edit')"
  78. @click="handleEdit(record)"
  79. >修改</operation-button>
  80. <operation-button
  81. :type="2"
  82. :title="'是否要'+(record.closeProject?'开启':'关闭')+'该条数据?'"
  83. @confirm="updateClose(record)">{{ record.closeProject?'开启':'关闭' }}</operation-button>
  84. <operation-button
  85. v-if="$auth('fill-project-quantities-del')"
  86. :type="2"
  87. title="是否要删除该条数据?"
  88. @confirm="batchDelete(record.id)">删除</operation-button>
  89. </template>
  90. </span>
  91. </s-table>
  92. </a-col>
  93. </a-row>
  94. <base-form ref="baseModal" @ok="handleOk"/>
  95. <detail ref="detailModal"/>
  96. <import-form ref="importForm" @save="importDataSave" />
  97. </a-card>
  98. </template>
  99. <script>
  100. import { STable, Ellipsis } from '@/components'
  101. import BaseForm from './modules/BaseForm'
  102. import Detail from './modules/Detail'
  103. import { getFillProjectQuantityPage, getFillProjectQuantityDeptTree, updateCloseProject,
  104. deleteFillProjectQuantitys, fetchFillProjectQuantity, exportFillProjectQuantity, importProject } from '@/api/fill/project-quantity'
  105. import { getDeptTree } from '@/api/upms/dept'
  106. export default {
  107. name: 'FillProjectQuantityList',
  108. components: {
  109. STable,
  110. Ellipsis,
  111. BaseForm,
  112. Detail
  113. },
  114. data () {
  115. return {
  116. // 查询参数
  117. queryParam: {
  118. },
  119. selectedKeys: [],
  120. selectedItem: {},
  121. expandedKeys: [],
  122. treeData: [],
  123. fillProjectQuantityTree: [],
  124. autoExpandParent: true,
  125. // 表头
  126. columns: [
  127. {
  128. title: '序号',
  129. dataIndex: 'index',
  130. customRender: (text, record, index) => {
  131. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  132. }
  133. },
  134. {
  135. title: '部门',
  136. dataIndex: 'deptName'
  137. },
  138. {
  139. title: '章次',
  140. dataIndex: 'surah'
  141. },
  142. {
  143. title: '名称',
  144. dataIndex: 'name'
  145. },
  146. {
  147. title: '单位',
  148. dataIndex: 'unit',
  149. customRender: (text, record, index) => {
  150. return this.BaseTool.Table.getMapText(this.unitMap, text)
  151. }
  152. },
  153. {
  154. title: '位置单位',
  155. dataIndex: 'siteUnit',
  156. customRender: (text, record, index) => {
  157. return this.BaseTool.Table.getMapText(this.unitMap, text)
  158. }
  159. },
  160. {
  161. title: '总量',
  162. dataIndex: 'aggregate',
  163. customRender: (text, record, index) => {
  164. return this.BaseTool.Amount.formatter(text)
  165. }
  166. },
  167. {
  168. title: '单价',
  169. dataIndex: 'price',
  170. customRender: (text, record, index) => {
  171. return this.BaseTool.Amount.formatter(text)
  172. }
  173. },
  174. {
  175. title: '总价',
  176. dataIndex: 'totalPrice',
  177. customRender: (text, record, index) => {
  178. return this.BaseTool.Amount.formatter(text)
  179. }
  180. },
  181. {
  182. title: '备注',
  183. dataIndex: 'remark'
  184. },
  185. {
  186. title: '创建人名称',
  187. dataIndex: 'createdUserName'
  188. },
  189. {
  190. title: '创建日期',
  191. dataIndex: 'createdTime'
  192. },
  193. {
  194. title: '操作',
  195. key: 'action',
  196. width: '200px',
  197. align: 'center',
  198. scopedSlots: { customRender: 'action' }
  199. }
  200. ],
  201. // 下拉框map
  202. unitMap: {},
  203. // 加载数据方法 必须为 Promise 对象
  204. loadData: parameter => {
  205. parameter = {
  206. ...parameter,
  207. ...this.queryParam
  208. }
  209. return getFillProjectQuantityPage(parameter)
  210. .then(res => {
  211. return res.data
  212. })
  213. },
  214. selectedRowKeys: [],
  215. selectedRows: [],
  216. options: {
  217. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  218. rowSelection: {
  219. selectedRowKeys: this.selectedRowKeys,
  220. onChange: this.onSelectChange
  221. }
  222. },
  223. optionAlertShow: false
  224. }
  225. },
  226. created () {
  227. // 下拉框map
  228. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.FILL_PROJECT_QUANTITY_UNIT)
  229. this.initData()
  230. getDeptTree().then(res => {
  231. this.treeData = this.BaseTool.TREE.treeFilter(res.data, (item) => {
  232. if (item.item.nature === this.DictCache.VALUE.SYS_DEPT_NATURE.BAN_ZU) {
  233. return { delete: true }
  234. }
  235. item.deptCode = item.item.deptCode
  236. })
  237. })
  238. this.tableOption()
  239. },
  240. methods: {
  241. initData () {
  242. getFillProjectQuantityDeptTree().then(res => {
  243. this.fillProjectQuantityTree = this.BaseTool.TREE.treeFilter(res.data, (item) => {
  244. if (item.icon) {
  245. item.selectable = false
  246. }
  247. })
  248. })
  249. },
  250. tableOption () {
  251. if (!this.optionAlertShow) {
  252. this.options = {
  253. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  254. rowSelection: {
  255. selectedRowKeys: this.selectedRowKeys,
  256. onChange: this.onSelectChange,
  257. getCheckboxProps: record => ({
  258. props: {
  259. disabled: false,
  260. name: record.id
  261. }
  262. })
  263. }
  264. }
  265. this.optionAlertShow = true
  266. } else {
  267. this.options = {
  268. alert: false,
  269. rowSelection: null
  270. }
  271. this.optionAlertShow = false
  272. }
  273. },
  274. batchDelete (id) {
  275. let ids = []
  276. if (this.BaseTool.String.isBlank(id)) {
  277. const length = this.selectedRows.length
  278. if (length === 0) {
  279. this.$message.info('请选择要删除的记录')
  280. return
  281. }
  282. ids = this.selectedRows.map(item => item.id)
  283. } else {
  284. ids = [id]
  285. }
  286. deleteFillProjectQuantitys(ids).then(res => {
  287. this.$message.info('删除成功')
  288. this.handleOk()
  289. this.$refs.table.clearSelected()
  290. })
  291. },
  292. updateClose (record) {
  293. updateCloseProject({ id: record.id, closeProject: !record.closeProject }).then(res => {
  294. this.$message.info('操作成功')
  295. this.handleOk()
  296. })
  297. },
  298. handleEdit (record) {
  299. fetchFillProjectQuantity({ id: record.id }).then(res => {
  300. const modal = this.$refs.baseModal
  301. modal.base(res.data)
  302. })
  303. },
  304. handleView (record) {
  305. fetchFillProjectQuantity({ id: record.id }).then(res => {
  306. const modal = this.$refs.detailModal
  307. modal.base(res.data)
  308. })
  309. },
  310. handleOk () {
  311. this.initData()
  312. this.$refs.table.refresh()
  313. },
  314. onSelectChange (selectedRowKeys, selectedRows) {
  315. this.selectedRowKeys = selectedRowKeys
  316. this.selectedRows = selectedRows
  317. },
  318. resetSearchForm () {
  319. this.queryParam = {
  320. }
  321. this.selectedKeys = []
  322. this.selectedItem = {}
  323. this.$refs.table.refresh(true)
  324. },
  325. doImport () {
  326. this.$refs.importForm.base()
  327. },
  328. importDataSave (file, callback) {
  329. const result = importProject(file)
  330. .then((res) => {
  331. console.log(11111)
  332. this.handleOk()
  333. })
  334. callback(result)
  335. },
  336. doExport () {
  337. const parameter = {
  338. ...this.queryParam
  339. }
  340. exportFillProjectQuantity(parameter).then(file => {
  341. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  342. })
  343. },
  344. handleEnter () {
  345. this.$refs.table.refresh(true)
  346. },
  347. onSelect: function (selectedKeys, info) {
  348. this.selectedKeys = selectedKeys
  349. if (selectedKeys != null && selectedKeys.length > 0) {
  350. const select = info.node.$options.propsData.dataRef
  351. if (!select.icon) {
  352. this.selectedItem = info.node.$options.propsData.dataRef.item
  353. this.queryParam.parentId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  354. } else {
  355. this.selectedItem = {}
  356. this.queryParam.parentId = null
  357. this.queryParam.deptCode = info.node.$options.propsData.dataRef.item.deptCode
  358. }
  359. } else {
  360. this.selectedItem = {}
  361. this.queryParam.parentId = null
  362. this.queryParam.deptId = null
  363. }
  364. this.$refs.table.refresh(true)
  365. },
  366. onExpand (expandedKeys) {
  367. this.expandedKeys = expandedKeys
  368. this.autoExpandParent = false
  369. }
  370. }
  371. }
  372. </script>