StoreManagement.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <a-card class="StoreManagement" :bordered="false">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :span="6">
  8. <a-form-item class="search-item" label="门店名称">
  9. <a-input id="store-name" v-model.trim="queryParam.name" placeholder="请输入门店名称" @pressEnter="$refs.table.refresh(true)" allowClear />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :span="6">
  13. <a-form-item class="search-item" label="负责人手机">
  14. <a-input id="store-managerMobile" v-model.trim="queryParam.managerMobile" placeholder="请输入负责人手机" @pressEnter="$refs.table.refresh(true)" allowClear />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :span="6">
  18. <a-form-item class="search-item" label="组织机构">
  19. <!-- <a-input id="store-orgCode" v-model.trim="queryParam.orgCode" placeholder="请选择组织机构" @pressEnter="$refs.table.refresh(true)" allowClear /> -->
  20. <a-tree-select
  21. showSearch
  22. id="store-orgCode"
  23. v-model="queryParam.orgCode"
  24. allowClear
  25. :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  26. :tree-data="treeData"
  27. placeholder="请选择组织机构"
  28. treeNodeFilterProp="title">
  29. </a-tree-select>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :span="6">
  33. <a-form-item class="search-item" label="门店类型">
  34. <v-select
  35. id="store-type"
  36. ref="STORE_TYPE"
  37. allowClear
  38. placeholder="请选择门店类型"
  39. v-model="queryParam.selfFlag"
  40. code="STORE_BUSINESS_STATUS"></v-select>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :span="6">
  44. <a-form-item class="search-item" label="启用状态">
  45. <v-select
  46. id="store-status"
  47. ref="ENABLE_FLAG"
  48. allowClear
  49. placeholder="请选择启用状态"
  50. v-model="queryParam.isEnable"
  51. code="DEVICE_STATUS"></v-select>
  52. </a-form-item>
  53. </a-col>
  54. <a-col :span="6">
  55. <a-button type="primary" id="store-search" class="search-btn" @click="$refs.table.refresh(true)">查询</a-button>
  56. <a-button id="store-reset" @click="reset">重置</a-button>
  57. </a-col>
  58. </a-row>
  59. </a-form>
  60. </div>
  61. <!-- 表格列表 -->
  62. <s-table
  63. ref="table"
  64. size="default"
  65. :rowKey="(record) => record.id"
  66. :columns="columns"
  67. :data="loadData"
  68. bordered>
  69. <!-- 操作 -->
  70. <template slot="action" slot-scope="text, record">
  71. <a-icon type="edit" title="编辑" id="store-edit" @click="edit(record)" :style="{ fontSize: '20px', color: '#1890FF', padding: '0 10px' }" />
  72. <a-icon type="link" title="设置" id="store-set" @click="setEquipment(record)" :style="{ fontSize: '20px', color: '#e29e14', padding: '0 10px' }" />
  73. </template>
  74. </s-table>
  75. <!-- 编辑 门店所属组织 -->
  76. <store-modal :openModal="openModal" :storeId="storeId" @success="storeSubmit" @close="closeModal" />
  77. <!-- 门店 关联设备 -->
  78. <store-associated-equipment-modal :openModal="openEquipmentModal" :storeId="storeId" :storeCode="storeCode" @close="closeDetailsModal" />
  79. </a-card>
  80. </template>
  81. <script>
  82. import { STable, VSelect } from '@/components'
  83. import StoreModal from './StoreModal.vue'
  84. import StoreAssociatedEquipmentModal from './StoreAssociatedEquipmentModal.vue'
  85. // import { getProvince, getCityByPro } from '@/api/lookup'
  86. import { findStoreList } from '@/api/store.js'
  87. import { findOrgTree } from '@/api/atorg.js'
  88. export default {
  89. name: 'StoreManagement',
  90. components: { STable, VSelect, StoreModal, StoreAssociatedEquipmentModal },
  91. data () {
  92. return {
  93. queryParam: {
  94. name: '', // 门店名称
  95. managerMobile: '', // 负责人手机
  96. orgCode: null, // 组织机构
  97. selfFlag: '', // 门店类型
  98. isEnable: '' // 启用状态
  99. },
  100. columns: [
  101. { title: '序号', dataIndex: 'no', width: '40', align: 'center' },
  102. { title: '创建时间', dataIndex: 'createDate', width: '100', align: 'center' },
  103. { title: '组织机构', dataIndex: 'orgCodeName', width: '100', align: 'center' },
  104. { title: '门店名称', dataIndex: 'name', width: '100', align: 'center' },
  105. { title: '门店类型', dataIndex: 'selfFlag', width: '100', align: 'center' },
  106. { title: '负责人名称', dataIndex: 'managerName', width: '100', align: 'center' },
  107. { title: '负责人手机', dataIndex: 'managerMobile', width: '100', align: 'center' },
  108. { title: '启用状态', dataIndex: 'isEnable', width: '100', align: 'center' },
  109. { title: '操作', scopedSlots: { customRender: 'action' }, width: '265', align: 'center' }
  110. ],
  111. // 加载数据方法 必须为 Promise 对象
  112. loadData: parameter => {
  113. return findStoreList(Object.assign(parameter, this.queryParam)).then(res => {
  114. if (res.status == 200) {
  115. const no = (res.data.pageNo - 1) * res.data.pageSize
  116. for (let i = 0; i < res.data.list.length; i++) {
  117. const _item = res.data.list[i]
  118. _item.no = no + i + 1
  119. }
  120. res.data.count = Number(res.data.count)
  121. return res.data
  122. }
  123. })
  124. },
  125. openModal: false, // 编辑 门店所属组织 弹框展示状态
  126. openEquipmentModal: false, // 门店 关联设备 弹框展示状态
  127. storeId: '', // 门店id
  128. storeCode: '', // 门店code
  129. treeData: [] // 组织机构
  130. }
  131. },
  132. mounted () {
  133. this.getOrgList()
  134. },
  135. methods: {
  136. // 获取组织机构 数据
  137. getOrgList () {
  138. findOrgTree().then(res => {
  139. if (res.status == 200) {
  140. this.treeData = this.recursionFun(res.data)
  141. } else {
  142. this.treeData = []
  143. }
  144. })
  145. },
  146. // 递归函数
  147. recursionFun (data) {
  148. if (data) {
  149. data.map(item => {
  150. if (item.children && item.children.length == 0) {
  151. item.key = item.id ? 'org' + item.id : ''
  152. item.value = item.code ? item.code : ''
  153. item.title = item.name ? item.name : ''
  154. } else {
  155. item.key = item.id ? 'org' + item.id : ''
  156. item.value = item.code ? item.code : ''
  157. item.title = item.name ? item.name : ''
  158. this.recursionFun(item.children)
  159. }
  160. })
  161. }
  162. return data
  163. },
  164. // 编辑
  165. edit (item) {
  166. this.storeId = String(item.id)
  167. this.storeCode = String(item.code)
  168. this.openModal = true
  169. this.openEquipmentModal = false
  170. },
  171. // 新增编辑 提交成功
  172. storeSubmit () {
  173. this.$refs.table.refresh(true)
  174. this.openModal = false
  175. },
  176. // 设置
  177. setEquipment (item) {
  178. this.storeId = String(item.id)
  179. this.storeCode = String(item.code)
  180. this.openEquipmentModal = true
  181. this.openModal = false
  182. },
  183. // 重置
  184. reset () {
  185. this.queryParam = {
  186. name: '', // 门店名称
  187. managerMobile: '', // 负责人手机
  188. orgCode: null, // 组织机构
  189. selfFlag: '', // 门店类型
  190. isEnable: '' // 启用状态
  191. }
  192. this.addrCityList = []
  193. this.$refs.table.refresh(true)
  194. },
  195. // 新增、编辑 弹框关闭
  196. closeModal () {
  197. this.storeId = ''
  198. this.storeCode = ''
  199. this.openModal = false
  200. },
  201. // 关联设备 弹框关闭
  202. closeDetailsModal () {
  203. this.storeId = ''
  204. this.storeCode = ''
  205. this.openEquipmentModal = false
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="less">
  211. .StoreManagement {
  212. .table-page-search-wrapper {
  213. .search-btn {
  214. margin-right: 10px;
  215. }
  216. }
  217. }
  218. </style>