index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
  4. <el-form-item label="姓名" prop="contactName">
  5. <el-input
  6. v-model="queryParams.contactName"
  7. placeholder="请输入姓名"
  8. clearable
  9. @keyup.enter="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="人员编号" prop="contactNo">
  13. <el-input
  14. v-model="queryParams.contactNo"
  15. placeholder="请输入人员编号"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="手机号码" prop="phone">
  21. <el-input
  22. v-model="queryParams.phone"
  23. placeholder="请输入手机号码"
  24. clearable
  25. @keyup.enter="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  30. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button
  36. type="primary"
  37. plain
  38. icon="Plus"
  39. @click="handleAdd"
  40. >新增</el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="success"
  45. plain
  46. icon="Edit"
  47. :disabled="single"
  48. @click="handleUpdate"
  49. >修改</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. type="danger"
  54. plain
  55. icon="Delete"
  56. :disabled="multiple"
  57. @click="handleDelete"
  58. >删除</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="warning"
  63. plain
  64. icon="Download"
  65. @click="handleExport"
  66. >导出</el-button>
  67. </el-col>
  68. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  69. </el-row>
  70. <el-table v-loading="loading" :data="contactPersonList" @selection-change="handleSelectionChange" border>
  71. <el-table-column type="selection" width="55" align="center" />
  72. <el-table-column label="联系人" align="center" prop="contactName">
  73. <template #default="scope">
  74. <span class="contact-name-text">{{ scope.row.contactName }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="部门" align="center" prop="deptName" />
  78. <el-table-column label="客户名称" align="left" prop="customerName" :show-overflow-tooltip="true" />
  79. <el-table-column label="职位" align="center" prop="roleName" />
  80. <el-table-column label="手机号码" align="center" prop="phone" />
  81. <el-table-column label="办公电话" align="center" prop="officePhone" />
  82. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  83. <template #default="scope">
  84. <el-button link type="primary" @click="handleUpdate(scope.row)">详情</el-button>
  85. <el-button link type="info" @click="handleDelete(scope.row)">删除</el-button>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <pagination
  90. v-show="total > 0"
  91. :total="total"
  92. v-model:page="queryParams.pageNum"
  93. v-model:limit="queryParams.pageSize"
  94. @pagination="getList"
  95. />
  96. <!-- 添加或修改联系人对话框 -->
  97. <el-dialog :title="title" v-model="open" width="800px" append-to-body>
  98. <el-form ref="contactPersonRef" :model="form" :rules="rules" label-width="100px">
  99. <el-tabs v-model="activeTab">
  100. <el-tab-pane label="基本信息" name="basic">
  101. <el-row>
  102. <el-col :span="12">
  103. <el-form-item label="人员编号" prop="contactNo">
  104. <el-input v-model="form.contactNo" placeholder="请输入人员编号" />
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="12">
  108. <el-form-item label="姓名" prop="contactName">
  109. <el-input v-model="form.contactName" placeholder="请输入姓名" />
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="12">
  113. <el-form-item label="性别" prop="gender">
  114. <el-select v-model="form.gender" placeholder="请选择性别">
  115. <el-option label="男" value="0" />
  116. <el-option label="女" value="1" />
  117. </el-select>
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="12">
  121. <el-form-item label="生日" prop="birthday">
  122. <el-date-picker clearable
  123. v-model="form.birthday"
  124. type="date"
  125. value-format="YYYY-MM-DD"
  126. placeholder="请选择生日">
  127. </el-date-picker>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="12">
  131. <el-form-item label="角色" prop="roleName">
  132. <el-input v-model="form.roleName" placeholder="请输入角色" />
  133. </el-form-item>
  134. </el-col>
  135. </el-row>
  136. </el-tab-pane>
  137. <el-tab-pane label="工作信息" name="work">
  138. <el-row>
  139. <el-col :span="12">
  140. <el-form-item label="客户名称" prop="customerName">
  141. <el-input v-model="form.customerName" placeholder="请输入客户名称" />
  142. </el-form-item>
  143. </el-col>
  144. <el-col :span="12">
  145. <el-form-item label="部门" prop="deptName">
  146. <el-input v-model="form.deptName" placeholder="请输入部门" />
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. </el-tab-pane>
  151. <el-tab-pane label="联系方式" name="contact">
  152. <el-row>
  153. <el-col :span="12">
  154. <el-form-item label="手机号码" prop="phone">
  155. <el-input v-model="form.phone" placeholder="请输入手机号码" />
  156. </el-form-item>
  157. </el-col>
  158. <el-col :span="12">
  159. <el-form-item label="座机" prop="officePhone">
  160. <el-input v-model="form.officePhone" placeholder="请输入座机" />
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="24">
  164. <el-form-item label="办公地址" prop="addressDetail">
  165. <el-input v-model="form.addressDetail" placeholder="请输入办公地址" />
  166. </el-form-item>
  167. </el-col>
  168. </el-row>
  169. </el-tab-pane>
  170. <el-tab-pane label="其他" name="other">
  171. <el-row>
  172. <el-col :span="24">
  173. <el-form-item label="备注" prop="remark">
  174. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  175. </el-form-item>
  176. </el-col>
  177. </el-row>
  178. </el-tab-pane>
  179. </el-tabs>
  180. </el-form>
  181. <template #footer>
  182. <div class="dialog-footer">
  183. <el-button type="primary" @click="submitForm">确 定</el-button>
  184. <el-button @click="cancel">取 消</el-button>
  185. </div>
  186. </template>
  187. </el-dialog>
  188. </div>
  189. </template>
  190. <script setup name="ContactPerson">
  191. import { ref, reactive, toRefs, getCurrentInstance, onMounted } from 'vue';
  192. import { listContactPerson, getContactPerson, delContactPerson, addContactPerson, updateContactPerson } from "@/api/customer/contactPerson";
  193. const { proxy } = getCurrentInstance();
  194. const contactPersonList = ref([]);
  195. const open = ref(false);
  196. const loading = ref(true);
  197. const showSearch = ref(true);
  198. const ids = ref([]);
  199. const single = ref(true);
  200. const multiple = ref(true);
  201. const total = ref(0);
  202. const title = ref("");
  203. const activeTab = ref("basic");
  204. const data = reactive({
  205. form: {},
  206. queryParams: {
  207. pageNum: 1,
  208. pageSize: 10,
  209. contactName: null,
  210. contactNo: null,
  211. phone: null,
  212. customerId: null,
  213. customerName: null,
  214. roleId: null
  215. },
  216. rules: {
  217. contactName: [
  218. { required: true, message: "姓名不能为空", trigger: "blur" }
  219. ],
  220. }
  221. });
  222. const { queryParams, form, rules } = toRefs(data);
  223. /** 查询联系人列表 */
  224. function getList() {
  225. loading.value = true;
  226. listContactPerson(queryParams.value).then(response => {
  227. contactPersonList.value = response.rows;
  228. total.value = response.total;
  229. loading.value = false;
  230. });
  231. }
  232. // 取消按钮
  233. function cancel() {
  234. open.value = false;
  235. reset();
  236. }
  237. // 表单重置
  238. function reset() {
  239. form.value = {
  240. id: null,
  241. contactNo: null,
  242. contactName: null,
  243. roleId: null,
  244. roleName: null,
  245. gender: null,
  246. birthday: null,
  247. customerId: null,
  248. customerName: null,
  249. phone: null,
  250. deptId: null,
  251. deptName: null,
  252. officePhone: null,
  253. addressDetail: null,
  254. status: null,
  255. remark: null
  256. };
  257. proxy.resetForm("contactPersonRef");
  258. }
  259. /** 搜索按钮操作 */
  260. function handleQuery() {
  261. queryParams.value.pageNum = 1;
  262. getList();
  263. }
  264. /** 重置按钮操作 */
  265. function resetQuery() {
  266. proxy.resetForm("queryRef");
  267. handleQuery();
  268. }
  269. // 多选框选中数据
  270. function handleSelectionChange(selection) {
  271. ids.value = selection.map(item => item.id);
  272. single.value = selection.length != 1;
  273. multiple.value = !selection.length;
  274. }
  275. /** 新增按钮操作 */
  276. function handleAdd() {
  277. reset();
  278. open.value = true;
  279. title.value = "添加联系人";
  280. }
  281. /** 修改按钮操作 */
  282. function handleUpdate(row) {
  283. reset();
  284. const _id = row.id || ids.value
  285. getContactPerson(_id).then(response => {
  286. form.value = response.data;
  287. open.value = true;
  288. title.value = "修改联系人";
  289. });
  290. }
  291. /** 提交按钮 */
  292. function submitForm() {
  293. proxy.$refs["contactPersonRef"].validate(valid => {
  294. if (valid) {
  295. if (form.value.id != null) {
  296. updateContactPerson(form.value).then(response => {
  297. proxy.$modal.msgSuccess("修改成功");
  298. open.value = false;
  299. getList();
  300. });
  301. } else {
  302. addContactPerson(form.value).then(response => {
  303. proxy.$modal.msgSuccess("新增成功");
  304. open.value = false;
  305. getList();
  306. });
  307. }
  308. }
  309. });
  310. }
  311. /** 删除按钮操作 */
  312. function handleDelete(row) {
  313. const _ids = row.id || ids.value;
  314. proxy.$modal.confirm('是否确认删除联系人编号为"' + _ids + '"的数据项?').then(function() {
  315. return delContactPerson(_ids);
  316. }).then(() => {
  317. getList();
  318. proxy.$modal.msgSuccess("删除成功");
  319. }).catch(() => {});
  320. }
  321. /** 导出按钮操作 */
  322. function handleExport() {
  323. proxy.download('/customer/customerContact/export', {
  324. ...queryParams.value
  325. }, `contactPerson_${new Date().getTime()}.xlsx`)
  326. }
  327. getList();
  328. </script>
  329. <style scoped>
  330. /* 表头背景色和文字样式 */
  331. :deep(.el-table th.el-table__cell) {
  332. background-color: #f8f9fb !important;
  333. color: #333 !important;
  334. height: 50px;
  335. font-weight: normal !important;
  336. }
  337. /* 联系人名称颜色(原型图中为橙色) */
  338. .contact-name-text {
  339. color: #ff9900;
  340. }
  341. /* 表格行高调整 */
  342. :deep(.el-table .el-table__cell) {
  343. padding: 8px 0;
  344. }
  345. /* 操作按钮间距 */
  346. .el-button--link {
  347. margin: 0 5px;
  348. }
  349. </style>