list.vue 7.9 KB

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