shelfModal.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div>
  3. <a-modal
  4. centered
  5. wrapClassName="settlementModifyModal-modal"
  6. :footer="null"
  7. :maskClosable="false"
  8. title="选择参与货架"
  9. v-model="isshow"
  10. @cancle="handleBack"
  11. width="80%">
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <div ref="tableSearch" class="table-page-search-wrapper">
  14. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-item label="货架名称">
  18. <a-input id="goodsShelvesAdministrationList-shelfName" allowClear v-model.trim="queryParam.shelfName" placeholder="请输入货架名称"/>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-item label="配件经销商">
  23. <dealerList ref="dealerList" @change="dealerChange" id="goodsShelvesAdministrationList-dealerChange"></dealerList>
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <a-form-item label="汽车修理厂">
  28. <storeList ref="storeList" @change="storeChange" id="goodsShelvesAdministrationList-storeChange"></storeList>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  32. <a-button type="primary" @click="$refs.table.refresh(true)" id="goodsShelvesAdministrationList-search">查询</a-button>
  33. <a-button type="" @click="reset" id="goodsShelvesAdministrationList-reset" style="margin-left: 10px;">重置</a-button>
  34. </a-col>
  35. </a-row>
  36. </a-form>
  37. </div>
  38. <s-table
  39. class="sTable"
  40. ref="table"
  41. size="small"
  42. rowKey="shelfSn"
  43. :columns="columns"
  44. :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: !!record.rewardRuleStoreList && !checkedList.find(item=>item.shelfSn==record.shelfSn) } })}"
  45. @rowSelection="rowSelectionFun"
  46. :data="loadData"
  47. :defaultLoadData="false"
  48. :scroll="{ y: 350 }"
  49. bordered>
  50. <template slot="ruleName" slot-scope="text, record">
  51. <div v-if="record.rewardRuleStoreList">
  52. <div v-for="item in record.rewardRuleStoreList" :key="item.id">
  53. {{ item.rewardRule.ruleName }}({{ item.rewardRule.ruleStatusDictValue }})
  54. </div>
  55. </div>
  56. </template>
  57. </s-table>
  58. <div style="padding:10px;text-align:center;">
  59. <a-button type="default" @click="handleBack" style="margin-right:20px;">取消</a-button>
  60. <a-button type="primary" @click="handleOk">确定</a-button>
  61. </div>
  62. </a-spin>
  63. </a-modal>
  64. </div>
  65. </template>
  66. <script>
  67. import { STable, VSelect } from '@/components'
  68. import { rewardRuleShelfQueryPage } from '@/api/redPacket.js'
  69. import dealerList from '@/views/common/dealerList.vue'
  70. import storeList from '@/views/common/storeList.vue'
  71. export default {
  72. name: 'ShelfModal',
  73. components: {
  74. STable, VSelect, storeList, dealerList
  75. },
  76. props: {
  77. visible: {
  78. type: Boolean,
  79. default: false
  80. },
  81. checkedList: {
  82. type: Array,
  83. default: function () {
  84. return []
  85. }
  86. }
  87. },
  88. data () {
  89. return {
  90. spinning: false,
  91. isshow: this.visible,
  92. // 查询参数
  93. queryParam: {
  94. dealerSn: undefined, // 配件经销商sn
  95. shelfName: '', // 货架名称
  96. storeSn: undefined, // 汽车修理厂
  97. state: 'ENABLE'
  98. },
  99. // 表头
  100. columns: [
  101. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  102. { title: '货架名称', dataIndex: 'shelfName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  103. { title: '配件经销商', dataIndex: 'dealerName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  104. { title: '汽车修理厂', dataIndex: 'storeName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  105. { title: '货架状态', dataIndex: 'stateDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: <div>已参加活动&nbsp;<a-tooltip placement='top' title='如果货架存在未开始或进行中的红包活动,则不能再参与其它红包活动。'><a-icon type="question-circle" /></a-tooltip></div>, width: '20%', align: 'center', scopedSlots: { customRender: 'ruleName' } }
  107. ],
  108. // 加载数据方法 必须为 Promise 对象
  109. loadData: parameter => {
  110. this.spinning = true
  111. return rewardRuleShelfQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
  112. let data
  113. if (res.status == 200) {
  114. data = res.data
  115. const no = (data.pageNo - 1) * data.pageSize
  116. for (let i = 0; i < data.list.length; i++) {
  117. const _item = data.list[i]
  118. _item.no = no + i + 1
  119. }
  120. }
  121. this.setCheckList()
  122. this.spinning = false
  123. return data
  124. })
  125. },
  126. rowSelectionInfo: null
  127. }
  128. },
  129. methods: {
  130. // 表格选中项
  131. rowSelectionFun (obj) {
  132. this.rowSelectionInfo = obj || null
  133. },
  134. // 经销商 change
  135. dealerChange (obj) {
  136. this.queryParam.dealerSn = obj.key || undefined
  137. },
  138. // 汽车修理厂 change
  139. storeChange (obj) {
  140. this.queryParam.storeSn = obj.key || undefined
  141. },
  142. // 设置已选中项
  143. setCheckList () {
  144. const selected = []
  145. this.checkedList.map(item => {
  146. selected.push(item.shelfSn)
  147. })
  148. this.$refs.table.setTableSelected(selected, [])
  149. },
  150. handleBack () {
  151. this.$emit('close')
  152. },
  153. handleOk () {
  154. const _this = this
  155. console.log(_this.rowSelectionInfo)
  156. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  157. _this.$message.warning('请选择货架!')
  158. return
  159. }
  160. const ret = []
  161. _this.rowSelectionInfo.selectedRowKeys.map(item => {
  162. ret.push({
  163. 'shelfSn': item
  164. })
  165. })
  166. this.$emit('ok', ret)
  167. },
  168. // 重置
  169. reset (flag) {
  170. this.queryParam = {
  171. dealerSn: undefined, // 配件经销商sn
  172. shelfName: '', // 货架名称
  173. storeSn: undefined, // 汽车修理厂
  174. state: 'ENABLE'
  175. }
  176. this.$refs.dealerList.resetForm()
  177. this.$refs.storeList.resetForm()
  178. this.$refs.table.refresh(true)
  179. }
  180. },
  181. watch: {
  182. visible (newValue, oldValue) {
  183. this.isshow = newValue
  184. },
  185. isshow (newValue, oldValue) {
  186. if (!newValue) {
  187. this.$emit('close')
  188. } else {
  189. this.$nextTick(() => {
  190. this.reset(true)
  191. })
  192. }
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="less">
  198. .settlementModifyModal-modal{
  199. .ant-input-number-handler-wrap{
  200. display: none;
  201. }
  202. }
  203. </style>