You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

591 lines
20 KiB

1 year ago
1 year ago
  1. <template>
  2. <a-row :gutter="10">
  3. <a-col :md="leftColMd" :sm="24" style="margin-bottom: 20px">
  4. <a-card :bordered="false">
  5. <!-- 查询区域 -->
  6. <div class="table-page-search-wrapper">
  7. <!-- 搜索区域 -->
  8. <a-form layout="inline" @keyup.enter.native="searchQuery">
  9. <a-row :gutter="24">
  10. <a-col :md="12" :sm="8">
  11. <a-form-item label="商品标题" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
  12. <a-input placeholder="" v-model="queryParam.name"></a-input>
  13. </a-form-item>
  14. </a-col>
  15. <!--
  16. <a-col :md="11" :sm="12">
  17. <a-form-item label="创建时间" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
  18. <j-date v-model="queryParam.createTime_begin" :showTime="true" date-format="YYYY-MM-DD HH:mm:ss" style="width:45%" placeholder="请选择开始时间" ></j-date>
  19. <span style="width: 10px;">~</span>
  20. <j-date v-model="queryParam.createTime_end" :showTime="true" date-format="YYYY-MM-DD HH:mm:ss" style="width:45%" placeholder="请选择结束时间"></j-date>
  21. </a-form-item>
  22. </a-col>
  23. -->
  24. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  25. <a-col :md="12" :sm="24">
  26. <a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 21px">查询</a-button>
  27. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  28. </a-col>
  29. </span>
  30. </a-row>
  31. </a-form>
  32. </div>
  33. <!-- 操作按钮区域 -->
  34. <div class="table-operator" style="margin: 5px 0 10px 2px">
  35. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  36. <!--<a-button @click="handleEdit(model1)" type="primary" icon="plus">角色编辑</a-button>-->
  37. <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
  38. <!-- <a-button type="primary" icon="import">导入</a-button>-->
  39. <!-- </a-upload>-->
  40. <!-- <a-button type="primary" icon="download" @click="handleExportXls('角色管理')">导出</a-button>-->
  41. </div>
  42. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  43. <i class="anticon anticon-info-circle ant-alert-icon">
  44. </i> 已选择 <a><b>{{ selectedRowKeys1.length }}</b></a>
  45. <a style="margin-left: 24px" @click="onClearSelected1">清空</a>
  46. </div>
  47. <div style="margin-top: 15px">
  48. <a-table
  49. style="height:500px"
  50. ref="table"
  51. size="middle"
  52. bordered
  53. rowKey="id"
  54. :columns="columns"
  55. :dataSource="dataSource"
  56. :pagination="ipagination"
  57. :loading="loading"
  58. :rowSelection="{selectedRowKeys: selectedRowKeys1, onChange: onSelectChange1, type:'radio'}"
  59. @change="handleTableChange">
  60. <template slot="imgSlot" slot-scope="text,record">
  61. <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
  62. <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
  63. </template>
  64. <span slot="action" slot-scope="text, record">
  65. <a @click="handleOpen(record)">规格</a>
  66. <a-divider type="vertical"/>
  67. <a-dropdown>
  68. <a class="ant-dropdown-link">
  69. 更多 <a-icon type="down"/>
  70. </a>
  71. <a-menu slot="overlay">
  72. <!-- <a-menu-item>-->
  73. <!-- <a @click="handlePerssion(record.id)">授权</a>-->
  74. <!-- </a-menu-item>-->
  75. <a-menu-item>
  76. <a @click="handleEdit(record)">编辑</a>
  77. </a-menu-item>
  78. <a-menu-item>
  79. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete1(record.id)">
  80. <a>删除</a>
  81. </a-popconfirm>
  82. </a-menu-item>
  83. </a-menu>
  84. </a-dropdown>
  85. </span>
  86. </a-table>
  87. </div>
  88. <!-- 右侧的角色权限配置 -->
  89. <user-role-modal ref="modalUserRole"></user-role-modal>
  90. <hotel-goods-modal ref="modalForm" @ok="modalFormOk"></hotel-goods-modal>
  91. </a-card>
  92. </a-col>
  93. <a-col :md="rightColMd" :sm="24" v-if="this.rightcolval == 1">
  94. <a-card :bordered="false">
  95. <div style="text-align: right;">
  96. <a-icon type="close-circle" @click="hideUserList" />
  97. </div>
  98. <!-- 查询区域 -->
  99. <div class="table-page-search-wrapper">
  100. <a-form layout="inline">
  101. <a-row :gutter="24">
  102. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  103. <a-col :md="9" :sm="24">
  104. <a-button type="primary" @click="searchQuery2" icon="search" style="margin-left: 21px">查询</a-button>
  105. <a-button type="primary" @click="searchReset2" icon="reload" style="margin-left: 8px">重置</a-button>
  106. </a-col>
  107. </span>
  108. </a-row>
  109. </a-form>
  110. </div>
  111. <!-- 操作按钮区域 -->
  112. <div class="table-operator" :md="24" :sm="24">
  113. <a-button @click="handleAdd2" type="primary" icon="plus" style="margin-top: 16px">新增规格</a-button>
  114. <!--<a-button @click="handleEdit2" type="primary" icon="edit" style="margin-top: 16px">用户编辑</a-button>-->
  115. <!-- <a-button @click="handleAddUserRole" type="primary" icon="plus" style="margin-top: 16px">已有用户</a-button>-->
  116. <a-dropdown v-if="selectedRowKeys2.length > 0">
  117. <a-menu slot="overlay">
  118. <a-menu-item key="1" @click="batchDel2">
  119. <a-icon type="delete"/>
  120. 删除
  121. </a-menu-item>
  122. </a-menu>
  123. <a-button style="margin-left: 8px"> 批量操作
  124. <a-icon type="down"/>
  125. </a-button>
  126. </a-dropdown>
  127. </div>
  128. <!-- table区域-begin -->
  129. <div>
  130. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  131. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
  132. selectedRowKeys2.length }}</a>
  133. <a style="margin-left: 24px" @click="onClearSelected2">清空</a>
  134. </div>
  135. <a-table
  136. style="height:500px"
  137. ref="table2"
  138. bordered
  139. size="middle"
  140. rowKey="id"
  141. :columns="columns2"
  142. :dataSource="dataSource2"
  143. :pagination="ipagination2"
  144. :loading="loading2"
  145. :rowSelection="{selectedRowKeys: selectedRowKeys2, onChange: onSelectChange2}"
  146. @change="handleTableChange2">
  147. <template slot="imgSlot" slot-scope="text,record">
  148. <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
  149. <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
  150. </template>
  151. <span slot="action" slot-scope="text, record">
  152. <a @click="handleEdit2(record)">编辑</a>
  153. <a-divider type="vertical"/>
  154. <a-dropdown>
  155. <a class="ant-dropdown-link">
  156. 更多 <a-icon type="down"/>
  157. </a>
  158. <a-menu slot="overlay">
  159. <a-menu-item>
  160. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete2(record.id)">
  161. <a>删除</a>
  162. </a-popconfirm>
  163. </a-menu-item>
  164. </a-menu>
  165. </a-dropdown>
  166. </span>
  167. </a-table>
  168. </div>
  169. <!-- 表单区域 -->
  170. <hotel-goods-modal ref="modalForm" @ok="modalFormOk"></hotel-goods-modal>
  171. <hotel-goods-sku-modal ref="modalForm2" @ok="modalFormOk2"></hotel-goods-sku-modal>
  172. <Select-User-Modal ref="selectUserModal" @selectFinished="selectOK"></Select-User-Modal>
  173. </a-card>
  174. </a-col>
  175. </a-row>
  176. </template>
  177. <script>
  178. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  179. import { deleteAction, postAction, getAction } from '@/api/manage'
  180. import SelectUserModal from './modules/SelectUserModal'
  181. import RoleModal from './modules/RoleModal'
  182. import HotelGoodsSkuModal from './modules/HotelGoodsSkuModal'
  183. import { filterObj } from '@/utils/util'
  184. import UserRoleModal from './modules/UserRoleModal'
  185. import HotelGoodsModal from "./modules/HotelGoodsModal";
  186. import moment from 'moment'
  187. export default {
  188. name: 'GoodsList',
  189. mixins: [JeecgListMixin],
  190. components: {
  191. UserRoleModal,
  192. SelectUserModal,
  193. HotelGoodsModal,
  194. HotelGoodsSkuModal,
  195. moment
  196. },
  197. data() {
  198. return {
  199. model1: {},
  200. model2: {},
  201. currentRoleId: '',
  202. queryParam1: {},
  203. queryParam2: {},
  204. dataSource1: [],
  205. dataSource2: [],
  206. ipagination1: {
  207. current: 1,
  208. pageSize: 10,
  209. pageSizeOptions: ['10', '20', '30'],
  210. showTotal: (total, range) => {
  211. return range[0] + '-' + range[1] + ' 共' + total + '条'
  212. },
  213. showQuickJumper: true,
  214. showSizeChanger: true,
  215. total: 0
  216. },
  217. ipagination2: {
  218. current: 1,
  219. pageSize: 10,
  220. pageSizeOptions: ['10', '20', '30'],
  221. showTotal: (total, range) => {
  222. return range[0] + '-' + range[1] + ' 共' + total + '条'
  223. },
  224. showQuickJumper: true,
  225. showSizeChanger: true,
  226. total: 0
  227. },
  228. isorter1: {
  229. column: 'createTime',
  230. order: 'desc'
  231. },
  232. isorter2: {
  233. column: 'createTime',
  234. order: 'desc'
  235. },
  236. filters1: {},
  237. filters2: {},
  238. loading1: false,
  239. loading2: false,
  240. selectedRowKeys1: [],
  241. selectedRowKeys2: [],
  242. selectionRows1: [],
  243. selectionRows2: [],
  244. test:{},
  245. rightcolval:0,
  246. columns:
  247. [
  248. {
  249. title: '商品名',
  250. align: 'center',
  251. dataIndex: 'name'
  252. },
  253. {
  254. title:'商品图',
  255. align:"center",
  256. dataIndex: 'pic',
  257. scopedSlots: {customRender: 'imgSlot'}
  258. },
  259. {
  260. title:'商家',
  261. align:"center",
  262. dataIndex: 'shopId_dictText'
  263. },
  264. {
  265. title: '分类',
  266. align: 'center',
  267. dataIndex: 'categoryId_dictText'
  268. },
  269. {
  270. title:'规格',
  271. align:"center",
  272. dataIndex: 'skuId_dictText'
  273. },
  274. {
  275. title:'是否上架',
  276. align:"center",
  277. dataIndex: 'upFlag_dictText'
  278. },
  279. {
  280. title:'排序',
  281. align:"center",
  282. dataIndex: 'sort',
  283. sorter: true,
  284. },
  285. {
  286. title: '创建时间',
  287. dataIndex: 'createTime',
  288. align:"center",
  289. sorter: true,
  290. customRender: (text) => {
  291. return moment(text).format('YYYY-MM-DD HH:mm:ss')
  292. }
  293. },
  294. {
  295. title: '操作',
  296. dataIndex: 'action',
  297. align: 'center',
  298. scopedSlots: { customRender: 'action' }
  299. }
  300. ],
  301. columns2: [{
  302. title: '标题',
  303. align: 'center',
  304. dataIndex: 'title',
  305. width: 120
  306. },
  307. {
  308. title:'商品图',
  309. align:"center",
  310. dataIndex: 'pic',
  311. scopedSlots: {customRender: 'imgSlot'}
  312. },
  313. {
  314. title: '原价',
  315. align: 'center',
  316. width: 100,
  317. dataIndex: 'originalPrice'
  318. },
  319. {
  320. title: '价格',
  321. align: 'center',
  322. width: 100,
  323. dataIndex: 'price'
  324. },
  325. {
  326. title: '排序',
  327. align: 'center',
  328. width: 80,
  329. sorter: true,
  330. dataIndex: 'sort'
  331. },
  332. {
  333. title: '操作',
  334. dataIndex: 'action',
  335. scopedSlots: { customRender: 'action' },
  336. align: 'center',
  337. width: 120
  338. }],
  339. // 高级查询参数
  340. superQueryParams2: '',
  341. // 高级查询拼接条件
  342. superQueryMatchType2: 'and',
  343. url: {
  344. list: '/hotelgoods/hotelGoods/list',
  345. delete: '/sys/role/delete',
  346. list2: '/hotelgoodssku/hotelGoodsSku/list',
  347. addUserRole: '/sys/user/addSysUserRole',
  348. delete2: '/sys/user/deleteUserRole',
  349. deleteBatch2: '/sys/user/deleteUserRoleBatch',
  350. exportXlsUrl: 'sys/role/exportXls',
  351. importExcelUrl: 'sys/role/importExcel'
  352. }
  353. }
  354. },
  355. computed: {
  356. importExcelUrl: function() {
  357. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
  358. },
  359. leftColMd() {
  360. return this.selectedRowKeys1.length === 0 ? 24 : 12
  361. },
  362. rightColMd() {
  363. return this.selectedRowKeys1.length === 0 ? 0 : 12
  364. }
  365. },
  366. methods: {
  367. onSelectChange2(selectedRowKeys, selectionRows) {
  368. this.selectedRowKeys2 = selectedRowKeys
  369. this.selectionRows2 = selectionRows
  370. },
  371. onClearSelected2() {
  372. this.selectedRowKeys2 = []
  373. this.selectionRows2 = []
  374. },
  375. onClearSelected1() {
  376. this.selectedRowKeys1 = []
  377. this.selectionRows1 = []
  378. },
  379. onSelectChange1(selectedRowKeys, selectionRows) {
  380. this.rightcolval = 1
  381. this.selectedRowKeys1 = selectedRowKeys
  382. this.selectionRows1 = selectionRows
  383. this.model1 = Object.assign({}, selectionRows[0])
  384. console.log(this.model1)
  385. this.currentRoleId = selectedRowKeys[0]
  386. this.loadData2()
  387. },
  388. onClearSelected() {
  389. },
  390. getQueryParams2() {
  391. //获取查询条件
  392. let sqp = {}
  393. if (this.superQueryParams2) {
  394. sqp['superQueryParams'] = encodeURI(this.superQueryParams2)
  395. sqp['superQueryMatchType'] = this.superQueryMatchType2
  396. }
  397. var param = Object.assign(sqp, this.queryParam2, this.isorter2, this.filters2)
  398. param.field = this.getQueryField2()
  399. param.pageNo = this.ipagination2.current
  400. param.pageSize = this.ipagination2.pageSize
  401. return filterObj(param)
  402. },
  403. getQueryField2() {
  404. //TODO 字段权限控制
  405. var str = 'id,'
  406. this.columns2.forEach(function(value) {
  407. str += ',' + value.dataIndex
  408. })
  409. return str
  410. },
  411. handleEdit2: function(record) {
  412. this.$refs.modalForm2.title = '编辑'
  413. this.$refs.modalForm2.roleDisabled = true
  414. this.$refs.modalForm2.edit(record)
  415. },
  416. handleAdd2: function() {
  417. if (this.currentRoleId == '') {
  418. this.$message.error('请选择一个角色!')
  419. } else {
  420. this.$refs.modalForm2.roleDisabled = true
  421. this.$refs.modalForm2.title = '新增'
  422. this.$refs.modalForm2.edit({activitiSync:'1',userIdentity:1,selectedroles:this.currentRoleId})
  423. }
  424. },
  425. modalFormOk2() {
  426. // 新增/修改 成功时,重载列表
  427. this.loadData2()
  428. },
  429. loadData2(arg) {
  430. if (!this.url.list2) {
  431. this.$message.error('请设置url.list2属性!')
  432. return
  433. }
  434. //加载数据 若传入参数1则加载第一页的内容
  435. if (arg === 1) {
  436. this.ipagination2.current = 1
  437. }
  438. if (this.currentRoleId === '') return
  439. let params = this.getQueryParams2()//查询条件
  440. params.goodsId = this.currentRoleId
  441. this.loading2 = true
  442. getAction(this.url.list2, params).then((res) => {
  443. if (res.success) {
  444. this.dataSource2 = res.result.records
  445. this.ipagination2.total = res.result.total
  446. }
  447. this.loading2 = false
  448. })
  449. },
  450. handleDelete1: function(id) {
  451. this.handleDelete(id)
  452. this.dataSource2 = []
  453. this.currentRoleId = ''
  454. },
  455. handleDelete2: function(id) {
  456. if (!this.url.delete2) {
  457. this.$message.error('请设置url.delete2属性!')
  458. return
  459. }
  460. var that = this
  461. deleteAction(that.url.delete2, { roleId: this.currentRoleId, userId: id }).then((res) => {
  462. if (res.success) {
  463. that.$message.success(res.message)
  464. that.loadData2()
  465. } else {
  466. that.$message.warning(res.message)
  467. }
  468. })
  469. },
  470. batchDel2: function() {
  471. if (!this.url.deleteBatch2) {
  472. this.$message.error('请设置url.deleteBatch2属性!')
  473. return
  474. }
  475. if (this.selectedRowKeys2.length <= 0) {
  476. this.$message.warning('请选择一条记录!')
  477. return
  478. } else {
  479. var ids = ''
  480. for (var a = 0; a < this.selectedRowKeys2.length; a++) {
  481. ids += this.selectedRowKeys2[a] + ','
  482. }
  483. var that = this
  484. console.log(this.currentDeptId)
  485. this.$confirm({
  486. title: '确认删除',
  487. content: '是否删除选中数据?',
  488. onOk: function() {
  489. deleteAction(that.url.deleteBatch2, { roleId: that.currentRoleId, userIds: ids }).then((res) => {
  490. if (res.success) {
  491. that.$message.success(res.message)
  492. that.loadData2()
  493. that.onClearSelected()
  494. } else {
  495. that.$message.warning(res.message)
  496. }
  497. })
  498. }
  499. })
  500. }
  501. },
  502. selectOK(data) {
  503. let params = {}
  504. params.roleId = this.currentRoleId
  505. params.userIdList = []
  506. for (var a = 0; a < data.length; a++) {
  507. params.userIdList.push(data[a])
  508. }
  509. console.log(params)
  510. postAction(this.url.addUserRole, params).then((res) => {
  511. if (res.success) {
  512. this.loadData2()
  513. this.$message.success(res.message)
  514. } else {
  515. this.$message.warning(res.message)
  516. }
  517. })
  518. },
  519. handleAddUserRole() {
  520. if (this.currentRoleId == '') {
  521. this.$message.error('请选择一个角色!')
  522. } else {
  523. this.$refs.selectUserModal.visible = true
  524. }
  525. },
  526. handleOpen(record) {
  527. this.rightcolval = 1
  528. this.selectedRowKeys1 = [record.id]
  529. this.model1 = Object.assign({}, record)
  530. this.currentRoleId = record.id
  531. this.onClearSelected2()
  532. this.loadData2()
  533. },
  534. /*handleEdit: function(record) {
  535. if (this.currentRoleId == '') {
  536. this.$message.error('请选择一个角色!')
  537. } else {
  538. this.$refs.modalForm.edit(record)
  539. this.$refs.modalForm.title = '编辑'
  540. }
  541. },*/
  542. searchQuery2() {
  543. this.loadData2(1)
  544. },
  545. searchReset2() {
  546. this.queryParam2 = {}
  547. this.loadData2(1)
  548. },
  549. handleTableChange2(pagination, filters, sorter) {
  550. //分页、排序、筛选变化时触发
  551. //TODO 筛选
  552. if (Object.keys(sorter).length > 0) {
  553. this.isorter2.column = sorter.field
  554. this.isorter2.order = 'ascend' == sorter.order ? 'asc' : 'desc'
  555. }
  556. this.ipagination2 = pagination
  557. this.loadData2()
  558. },
  559. hideUserList(){
  560. //this.rightcolval = 0
  561. this.selectedRowKeys1 = []
  562. },
  563. handlePerssion(roleId){
  564. this.$refs.modalUserRole.show(roleId);
  565. },
  566. }
  567. }
  568. </script>
  569. <style scoped>
  570. @import '~@assets/less/common.less';
  571. /** Button按钮间距 */
  572. .ant-btn {
  573. margin-left: 8px
  574. }
  575. </style>