list.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesmanList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="姓名">
  9. <a-input id="salesmanList-supplierName" v-model.trim="queryParam.name" allowClear placeholder="请输入姓名"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="状态">
  14. <v-select code="ENABLE_FLAG" id="salesmanList-enableFlag" v-model="queryParam.enableFlag" allowClear placeholder="请选择状态"></v-select>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="创建时间">
  19. <rangeDate ref="rangeDate" @change="dateChange" />
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesmanList-refresh">查询</a-button>
  24. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesmanList-reset">重置</a-button>
  25. </a-col>
  26. </a-row>
  27. </a-form>
  28. </div>
  29. <!-- 操作按钮 -->
  30. <div class="table-operator">
  31. <a-button
  32. v-if="$hasPermissions('B_salesman_add')"
  33. id="salesmanList-add"
  34. type="primary"
  35. class="button-error"
  36. @click="handleEdit()">新增</a-button>
  37. </div>
  38. <!-- 列表 -->
  39. <s-table
  40. class="sTable fixPagination"
  41. ref="table"
  42. :style="{ height: tableHeight+84.5+'px' }"
  43. size="small"
  44. :rowKey="(record) => record.id"
  45. :columns="columns"
  46. :data="loadData"
  47. :scroll="{ y: tableHeight }"
  48. :defaultLoadData="false"
  49. bordered>
  50. <!-- 操作 -->
  51. <template slot="action" slot-scope="text, record">
  52. <a-button
  53. size="small"
  54. type="link"
  55. class="button-primary"
  56. @click="handleEdit(record,1)"
  57. v-if="$hasPermissions('B_salesman_edit')"
  58. id="salesmanList-edit-btn">编辑</a-button>
  59. <a-button
  60. size="small"
  61. type="link"
  62. v-if="$hasPermissions('B_salesman_detail')"
  63. class="button-success"
  64. @click="handleEdit(record,2)"
  65. id="salesmanList-edit-btn">详情</a-button>
  66. <span v-else>--</span>
  67. </template>
  68. </s-table>
  69. <!-- 新增业务员 -->
  70. <salesman-edit-modal :itemId="itemId" :modalTitle="modalTitle" :openModal="openModal" @close="closeModal" />
  71. </a-card>
  72. </template>
  73. <script>
  74. import { commonMixin } from '@/utils/mixin'
  75. import { STable, VSelect } from '@/components'
  76. import { employeeList } from '@/api/salesman'
  77. import salesmanEditModal from './editModal.vue'
  78. import rangeDate from '@/views/common/rangeDate.vue'
  79. export default {
  80. name: 'SalesManList',
  81. components: { STable, VSelect, salesmanEditModal, rangeDate },
  82. mixins: [commonMixin],
  83. data () {
  84. return {
  85. advanced: true, // 高级搜索 展开/关闭
  86. modalTitle: '', // 弹窗title
  87. queryParam: { // 查询条件
  88. beginDate: '',
  89. endDate: '',
  90. name: '', // 姓名
  91. enableFlag: undefined // 状态
  92. },
  93. tableHeight: 0,
  94. disabled: false, // 查询、重置按钮是否可操作
  95. columns: [
  96. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  97. { title: '姓名', dataIndex: 'name', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  98. { title: '性别', dataIndex: 'sexDictValue', width: '10%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  99. { title: '联系电话', dataIndex: 'mobile', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  100. { title: '入职日期', dataIndex: 'entryDate', width: '15%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  101. { title: '创建时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  102. { title: '状态', dataIndex: 'enableFlagDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  104. ],
  105. // 加载数据方法 必须为 Promise 对象
  106. loadData: parameter => {
  107. this.disabled = true
  108. this.spinning = true
  109. return employeeList(Object.assign(parameter, this.queryParam)).then(res => {
  110. let data
  111. if (res.status == 200) {
  112. data = res.data
  113. const no = (data.pageNo - 1) * data.pageSize
  114. for (var i = 0; i < data.list.length; i++) {
  115. data.list[i].no = no + i + 1
  116. }
  117. this.disabled = false
  118. }
  119. this.spinning = false
  120. return data
  121. })
  122. },
  123. itemId: '', // 当前id
  124. openModal: false // 弹框
  125. }
  126. },
  127. methods: {
  128. // 时间 change
  129. dateChange (date) {
  130. this.queryParam.beginDate = date[0]
  131. this.queryParam.endDate = date[1]
  132. },
  133. // 重置
  134. resetSearchForm () {
  135. this.$refs.rangeDate.resetDate()
  136. this.queryParam = { // 查询条件
  137. beginDate: '',
  138. endDate: '',
  139. name: '', // 姓名
  140. enableFlag: undefined // 状态
  141. }
  142. this.$refs.table.refresh(true)
  143. },
  144. // 新增/编辑
  145. handleEdit (row, type) {
  146. if (row) {
  147. this.itemId = row && row.id ? row.id : null
  148. if (type == 1) {
  149. this.modalTitle = '编辑'
  150. } else {
  151. this.modalTitle = '详情'
  152. }
  153. } else {
  154. this.modalTitle = '新增'
  155. }
  156. this.openModal = true
  157. },
  158. // // 通过
  159. // handleSend (row) {
  160. // const _this = this
  161. // this.$confirm({
  162. // title: '提示',
  163. // content: '审核通过后该类型名称不能更改,确定审核通过该类型名称?',
  164. // centered: true,
  165. // closable: true,
  166. // onOk () {
  167. // _this.spinning = true
  168. // employeeAudit({
  169. // salesBillSn: row.id
  170. // }).then(res => {
  171. // if (res.status == 200) {
  172. // _this.$message.success(res.message)
  173. // _this.$refs.table.refresh()
  174. // _this.spinning = false
  175. // } else {
  176. // _this.spinning = false
  177. // }
  178. // })
  179. // }
  180. // })
  181. // },
  182. // 关闭弹框
  183. closeModal () {
  184. this.itemId = ''
  185. this.openModal = false
  186. this.$refs.table.refresh(true)
  187. },
  188. pageInit () {
  189. const _this = this
  190. this.$nextTick(() => { // 页面渲染完成后的回调
  191. _this.setTableH()
  192. })
  193. },
  194. setTableH () {
  195. const tableSearchH = this.$refs.tableSearch.offsetHeight
  196. this.tableHeight = window.innerHeight - tableSearchH - 245
  197. }
  198. },
  199. watch: {
  200. advanced (newValue, oldValue) {
  201. const _this = this
  202. this.$nextTick(() => { // 页面渲染完成后的回调
  203. _this.setTableH()
  204. })
  205. },
  206. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  207. this.setTableH()
  208. }
  209. },
  210. mounted () {
  211. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  212. this.pageInit()
  213. this.resetSearchForm()
  214. }
  215. },
  216. activated () {
  217. // 如果是新页签打开,则重置当前页面
  218. if (this.$store.state.app.isNewTab) {
  219. this.pageInit()
  220. this.resetSearchForm()
  221. }
  222. },
  223. beforeRouteEnter (to, from, next) {
  224. next(vm => {})
  225. }
  226. }
  227. </script>