sales_relation.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div class="screen-container">
  5. <div class="top clearfix">
  6. <div class="title fl">条件筛选</div>
  7. </div>
  8. <el-form ref="screenForm" :model="screenForm" label-width="70px" size="small" label-position="left">
  9. <el-row :gutter="20">
  10. <el-col :xs="24" :sm="12" :lg="6">
  11. <el-form-item label="业务员" prop="salesMan">
  12. <el-input v-model="screenForm.salesMan" placeholder="请输入业务员"></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :xs="24" :sm="12" :lg="6">
  16. <el-form-item label="业务线" prop="slaesLine">
  17. <el-input v-model="screenForm.slaesLine" placeholder="请输入业务线"></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :xs="24" :sm="24" :lg="12" class="tr">
  21. <el-form-item label="">
  22. <el-button size="small" @click="resetScreenForm">清空</el-button>
  23. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  24. </el-form-item>
  25. </el-col>
  26. </el-row>
  27. </el-form>
  28. </div>
  29. <div class="mymain-container">
  30. <div class="btn-group clearfix">
  31. <div class="fl">
  32. <el-button size="small" type="primary" icon="el-icon-plus" @click="openMainForm('add')">新增</el-button>
  33. </div>
  34. <div class="fr">
  35. <el-button size="small" type="primary" icon="el-icon-download" @click="handleExport">导出数据</el-button>
  36. </div>
  37. </div>
  38. <div class="table">
  39. <el-table
  40. v-loading="listLoading"
  41. :data="dataList"
  42. element-loading-text="Loading"
  43. border
  44. fit
  45. highlight-current-row
  46. stripe
  47. >
  48. <el-table-column
  49. align="center"
  50. label="业务员"
  51. prop="aaa"
  52. min-width="100"
  53. show-overflow-tooltip
  54. ></el-table-column>
  55. <el-table-column
  56. align="center"
  57. label="是否负责人"
  58. prop="aaa"
  59. min-width="100"
  60. show-overflow-tooltip
  61. ></el-table-column>
  62. <el-table-column
  63. align="center"
  64. label="业务线"
  65. prop="aaa"
  66. min-width="200"
  67. show-overflow-tooltip
  68. ></el-table-column>
  69. <el-table-column align="center" label="操作" width="100">
  70. <template slot-scope="scope">
  71. <el-button type="text" @click="openMainForm('edit', scope.row.id)">编辑</el-button>
  72. <el-popconfirm
  73. v-if="scope.row.status"
  74. style="margin-left: 10px"
  75. title="确定删除吗?"
  76. @onConfirm="handleDelete(scope.row.id, 0)"
  77. >
  78. <el-button slot="reference" type="text">删除</el-button>
  79. </el-popconfirm>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. </div>
  84. </div>
  85. <div class="pagination clearfix">
  86. <div class="fr">
  87. <el-pagination
  88. @size-change="handleSizeChange"
  89. @current-change="handleCurrentChange"
  90. :current-page="currentPage"
  91. :page-sizes="[10, 20, 30, 50]"
  92. :page-size="10"
  93. layout="total, sizes, prev, pager, next, jumper"
  94. :total="listTotal"
  95. >
  96. </el-pagination>
  97. </div>
  98. </div>
  99. <!-- 新增编辑 -->
  100. <el-dialog
  101. :title="mainFormType == 'add' ? '新增' : '编辑'"
  102. :visible.sync="mainFormVisible"
  103. :show-close="false"
  104. width="40%"
  105. :close-on-click-modal="false"
  106. >
  107. <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-position="left" label-width="70px">
  108. <el-form-item label="业务员" prop="salesMan">
  109. <el-select v-model="mainForm.salesMan" placeholder="请选择业务员" style="width: 100%">
  110. <el-option
  111. :label="item.name"
  112. :value="item.id"
  113. v-for="(item, index) in salesManList"
  114. :key="index"
  115. ></el-option>
  116. </el-select>
  117. </el-form-item>
  118. <el-form-item label="业务线" prop="salesLine">
  119. <el-select v-model="mainForm.salesLine" placeholder="请选择业务线" style="width: 100%">
  120. <el-option
  121. :label="item.name"
  122. :value="item.id"
  123. v-for="(item, index) in salesLineList"
  124. :key="index"
  125. ></el-option>
  126. </el-select>
  127. </el-form-item>
  128. </el-form>
  129. <div slot="footer" class="dialog-footer">
  130. <el-button @click="cancelMainForm">取 消</el-button>
  131. <el-button type="primary" @click="submitMainForm">确 定</el-button>
  132. </div>
  133. </el-dialog>
  134. </div>
  135. </template>
  136. <script>
  137. import { getRelationList } from '@/api/sales_region'
  138. import { downloadFiles } from '@/utils/util'
  139. export default {
  140. data() {
  141. return {
  142. currentPage: 1, // 当前页码
  143. pageSize: 10, // 每页数量
  144. listTotal: 0, // 列表总数
  145. dataList: null, // 列表数据
  146. listLoading: false, // 列表加载loading
  147. screenForm: {
  148. // 筛选表单数据
  149. salesMan: '',
  150. salesLine: ''
  151. },
  152. mainFormVisible: false,
  153. mainFormType: 'add',
  154. mainForm: {
  155. salesMan: '',
  156. salesLine: ''
  157. },
  158. mainFormRules: {
  159. salesMan: [{ required: true, message: '请选择业务员', trigger: 'change' }],
  160. salesLine: [{ required: true, message: '请选择业务线', trigger: 'change' }]
  161. },
  162. salesManList: [],
  163. salesLineList: []
  164. }
  165. },
  166. created() {
  167. this.getList()
  168. },
  169. methods: {
  170. // 查询按钮权限
  171. checkBtnRole(value) {
  172. // let btnRole = this.$route.meta.roles;
  173. // if(!btnRole) {return true}
  174. // let index = btnRole.indexOf(value);
  175. // return index >= 0;
  176. return true
  177. },
  178. // 查询列表
  179. getList() {
  180. this.listLoading = true
  181. let params = {
  182. pageNum: this.currentPage,
  183. pageSize: this.pageSize,
  184. userName: this.screenForm.account,
  185. nickName: this.screenForm.nickName,
  186. linkPhone: this.screenForm.phone,
  187. email: this.screenForm.email,
  188. status: this.screenForm.status
  189. }
  190. getRelationList(params).then(res => {
  191. this.dataList = res.data.records
  192. this.listTotal = res.data.total
  193. this.listLoading = false
  194. })
  195. },
  196. // 提交筛选表单
  197. submitScreenForm() {
  198. this.currentPage = 1
  199. this.getList()
  200. },
  201. // 重置筛选表单
  202. resetScreenForm() {
  203. this.$refs.screenForm.resetFields()
  204. this.currentPage = 1
  205. this.getList()
  206. },
  207. // 更改每页数量
  208. handleSizeChange(val) {
  209. this.pageSize = val
  210. this.currentPage = 1
  211. this.getList()
  212. },
  213. // 更改当前页
  214. handleCurrentChange(val) {
  215. this.currentPage = val
  216. this.getList()
  217. },
  218. // 打开 新增编辑
  219. openMainForm(type, id) {
  220. this.mainFormType = type
  221. this.mainFormVisible = true
  222. },
  223. // 取消 新增编辑 账号表单
  224. cancelMainForm() {
  225. this.mainFormVisible = false
  226. this.$refs.mainForm.resetFields()
  227. },
  228. // 提交
  229. submitMainForm() {
  230. this.$refs.mainForm.validate(valid => {
  231. if (valid) {
  232. let params = {
  233. password: this.mainForm.salesMan,
  234. password: this.mainForm.salesLine
  235. }
  236. resetPassword(params).then(res => {
  237. this.getList()
  238. this.cancelMainForm()
  239. this.$successMsg()
  240. })
  241. }
  242. })
  243. },
  244. // 导出
  245. handleExport() {
  246. let screenData = {
  247. userName: this.screenForm.account,
  248. nickName: this.screenForm.nickName,
  249. linkPhone: this.screenForm.phone,
  250. email: this.screenForm.email,
  251. status: this.screenForm.status
  252. }
  253. downloadFiles('admin/user/mch/export', screenData)
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="scss" scoped></style>