You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

385 lines
12 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div>
  3. <div style="display: flex">
  4. <div style="width: 95%">
  5. <el-table
  6. :data="customerOrg.contactPersonList"
  7. border
  8. height="150"
  9. row-key="id"
  10. size="small"
  11. class="el-table__body-wrapper tbody"
  12. highlight-current-row
  13. @row-click="rowClick"
  14. ref="customerOrg.contactPersonList"
  15. >
  16. <el-table-column prop="displayName" label="姓名" />
  17. <el-table-column prop="title" label="职务" />
  18. <el-table-column prop="remark" label="备注" />
  19. <el-table-column prop="creatorName" label="创建者" width="" />
  20. <el-table-column prop="creationTime" label="创建时间" width="200">
  21. <template slot-scope="scope">
  22. {{ scope.row.creationTime | dateFormat }}
  23. </template>
  24. </el-table-column>
  25. <el-table-column prop="lastModifierName" label="修改者" />
  26. <el-table-column
  27. prop="lastModificationTime"
  28. label="修改时间"
  29. width="200"
  30. >
  31. <template slot-scope="scope">
  32. {{ scope.row.lastModificationTime | dateFormat }}
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <el-table
  37. :data="customerOrg.contactMethodList"
  38. border
  39. height="150"
  40. row-key="id"
  41. size="small"
  42. class="el-table__body-wrapper tbody"
  43. highlight-current-row
  44. @row-click="rowClickMethod"
  45. ref="customerOrg.contactMethodList"
  46. >
  47. <el-table-column prop="contactMethodType" label="类型">
  48. <template slot-scope="scope">
  49. <div>
  50. {{ scope.row.contactMethodType === "0" ? "手机" : "邮箱" }}
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="contactMethodValue" label="联系方式" />
  55. <el-table-column prop="creatorName" label="创建者" width="" />
  56. <el-table-column prop="creationTime" label="创建时间" width="200">
  57. <template slot-scope="scope">
  58. {{ scope.row.creationTime | dateFormat }}
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="lastModifierName" label="修改者" />
  62. <el-table-column
  63. prop="lastModificationTime"
  64. label="修改时间"
  65. width="200"
  66. >
  67. <template slot-scope="scope">
  68. {{ scope.row.lastModificationTime | dateFormat }}
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. </div>
  73. <div style="margin-left: 10px; margin-top: 5%">
  74. <div style="margin-top: 10px">
  75. <el-button type="primary" @click="add">新增</el-button>
  76. </div>
  77. <div style="margin-top: 10px">
  78. <el-button type="success" @click="edit">编辑</el-button>
  79. </div>
  80. <div style="margin-top: 10px">
  81. <el-button type="danger" @click="del">删除</el-button>
  82. </div>
  83. </div>
  84. </div>
  85. <!-- 联系人 -->
  86. <el-dialog
  87. :title="formTitle"
  88. :visible.sync="dialogContactPerson"
  89. width="480"
  90. >
  91. <el-form :model="form" ref="form" label-width="100px" :rules="rules">
  92. <el-row>
  93. <el-col :span="8">
  94. <el-form-item label="联系人">
  95. <el-input v-model="form.displayName"></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="8">
  99. <el-form-item label="职务">
  100. <el-input v-model="form.title"></el-input>
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="8">
  104. <el-form-item label="备注">
  105. <el-input v-model="form.remark"></el-input>
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <el-row>
  110. <el-col :span="5">
  111. <el-form-item label="创建者">
  112. <el-input v-model="form.creatorName" disabled></el-input>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="7">
  116. <el-form-item label="创建时间" style="margin-left: -5%">
  117. <el-input
  118. :value="form.creationTime | dateFormat"
  119. disabled
  120. style="width: 90%"
  121. ></el-input>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="5">
  125. <el-form-item label="修改者" style="margin-left: -25%">
  126. <el-input v-model="form.creatorName" disabled></el-input>
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="7">
  130. <el-form-item label="修改时间" style="margin-left: -5%">
  131. <el-input
  132. :value="form.lastModificationTime | dateFormat"
  133. disabled
  134. style="width: 90%"
  135. ></el-input>
  136. </el-form-item>
  137. </el-col>
  138. </el-row>
  139. <el-divider />
  140. <el-table
  141. :data="customerOrg.contactMethodList"
  142. border
  143. height="300"
  144. row-key="id"
  145. size="small"
  146. class="el-table__body-wrapper tbody"
  147. highlight-current-row
  148. ref="contactMethod"
  149. >
  150. <el-table-column prop="contactMethodType" label="类型">
  151. <template slot-scope="scope">
  152. <el-select
  153. v-model="
  154. customerOrg.contactMethodList[scope.$index].contactMethodType
  155. "
  156. >
  157. <el-option
  158. v-for="item in Methodtypes"
  159. :key="item.value"
  160. :label="item.label"
  161. :value="item.value"
  162. />
  163. </el-select>
  164. </template>
  165. </el-table-column>
  166. <el-table-column prop="contactMethodValue" label="联系方式">
  167. <template slot-scope="scope">
  168. <el-input
  169. v-model="
  170. customerOrg.contactMethodList[scope.$index].contactMethodValue
  171. "
  172. required
  173. />
  174. </template>
  175. </el-table-column>
  176. <el-table-column fixed="right" label="操作" width="60">
  177. <template slot-scope="scope">
  178. <i
  179. class="el-icon-delete"
  180. @click="deleteRow(scope.$index)"
  181. size="medium"
  182. ></i>
  183. </template>
  184. </el-table-column>
  185. </el-table>
  186. </el-form>
  187. <span slot="footer" class="dialog-footer">
  188. <el-button @click="dialogContactPerson = false"> </el-button>
  189. <el-button type="success" @click="addMethod">新增联系方式</el-button>
  190. <el-button type="primary" @click="submit"> </el-button>
  191. </span>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import { mapState } from "vuex";
  197. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  198. import { objCopy } from "../../utlis/proFunc";
  199. export default {
  200. components: {},
  201. data() {
  202. return {
  203. personId: "",
  204. form: {}, //联系人表单信息
  205. formTitle: "新增",
  206. dialogContactPerson: false, //联系人弹窗 显示控制
  207. Methodtypes: [
  208. //{ value: '',label: '所有订单状态' },
  209. { value: "0", label: "电话" },
  210. { value: "1", label: "邮箱" },
  211. ],
  212. rules: {
  213. displayName: [
  214. { required: true, message: "请输入名称", trigger: "blur" },
  215. ],
  216. },
  217. };
  218. },
  219. created() {},
  220. //挂载完成
  221. mounted() {},
  222. computed: {
  223. ...mapState(["customerOrg"]),
  224. },
  225. methods: {
  226. //获取联系人列表
  227. getContactPersonList(customerOrgId) {
  228. getapi(
  229. `/api/app/contact-person/in-customer-org-id/${customerOrgId}`
  230. ).then((res) => {
  231. //console.log('res.data',res.data)
  232. this.customerOrg.contactPersonList = res.data;
  233. });
  234. },
  235. //获取联系方式列表
  236. //api/app/contact-method/in-contact-person-id?ContactPersonId=3a0c08ad-4304-138b-d9e6-a7338739dfc4' \
  237. getContactMethodList(ContactPersonId) {
  238. getapi("/api/app/contact-method/in-contact-person-id", {
  239. ContactPersonId,
  240. }).then((res) => {
  241. //console.log('res.data',res.data)
  242. this.customerOrg.contactMethodList = res.data;
  243. });
  244. },
  245. //联系人 相关操作
  246. add() {
  247. //this.$message.success("新增 addContactPerson");
  248. if (!this.customerOrg.customerOrgId) {
  249. alert("没有体检单位信息");
  250. return;
  251. }
  252. this.form = { customerOrgId: this.customerOrg.customerOrgId };
  253. this.dialogContactPerson = true;
  254. this.formTitle = "新增";
  255. this.personId = "";
  256. this.customerOrg.contactMethodList = [];
  257. },
  258. edit() {
  259. //this.$message.success("编辑 editContactPerson");
  260. if (!this.customerOrg.customerOrgId) {
  261. alert("没有体检单位信息");
  262. return;
  263. } else if (!this.personId) {
  264. alert("请先选择要编辑的联系人");
  265. return;
  266. }
  267. this.dialogContactPerson = true;
  268. this.formTitle = "编辑";
  269. },
  270. //删除联系人行
  271. del() {
  272. //this.$message.success("删除 delContactPerson");
  273. if (!this.personId) {
  274. alert("请先选择要编辑的联系人");
  275. return;
  276. }
  277. deletapi(`/api/app/contact-person/${this.personId}`).then((res) => {
  278. this.personId = "";
  279. this.getContactPersonList(this.customerOrg.customerOrgId);
  280. this.customerOrg.contactMethodList = [];
  281. this.$message.success("操作成功!");
  282. });
  283. },
  284. //删除联系方式行
  285. deleteRow(index) {
  286. this.customerOrg.contactMethodList.splice(index, 1);
  287. },
  288. //联系人信息提交
  289. submit() {
  290. let body = {
  291. customerOrgId: "",
  292. displayName: "",
  293. title: "",
  294. remark: "",
  295. };
  296. objCopy(this.form, body);
  297. console.log("body", body);
  298. if (this.formTitle === "新增") {
  299. postapi("/api/app/contact-person", body)
  300. .then((res) => {
  301. //console.log('api/app/contact-person')
  302. this.personId = res.data.id;
  303. this.formTitle = "编辑";
  304. return deletapi(`/api/app/contact-method/many/${this.personId}`);
  305. })
  306. .then((res) => {
  307. //console.log(`deletapi api/app/contact-method/${this.personId}`)
  308. let contactMethod = []; //联系方式form表单数据
  309. this.customerOrg.contactMethodList.forEach((item, index) => {
  310. contactMethod.push({
  311. contactMethodValue: item.contactMethodValue,
  312. contactMethodType: item.contactMethodType,
  313. contactPersonId: this.personId,
  314. });
  315. });
  316. return postapi("/api/app/contact-method/many", contactMethod);
  317. })
  318. .then((res) => {
  319. //console.log('api/app/contact-method/many')
  320. this.getContactPersonList(this.customerOrg.customerOrgId);
  321. this.$message.success("操作成功!");
  322. });
  323. } else {
  324. putapi(`/api/app/contact-person/${this.personId}`, body)
  325. .then((res) => {
  326. //console.log(`/api/app/contact-person/${this.personId}`)
  327. return deletapi(`/api/app/contact-method/many/${this.personId}`);
  328. })
  329. .then((res) => {
  330. console.log(`deletapi api/app/contact-method/${this.personId}`);
  331. let contactMethod = []; //联系方式form表单数据
  332. this.customerOrg.contactMethodList.forEach((item, index) => {
  333. contactMethod.push({
  334. contactMethodValue: item.contactMethodValue,
  335. contactMethodType: item.contactMethodType,
  336. contactPersonId: this.personId,
  337. });
  338. });
  339. return postapi("/api/app/contact-method/many", contactMethod);
  340. })
  341. .then((res) => {
  342. //console.log('api/app/contact-method/many')
  343. this.getContactPersonList(this.customerOrg.customerOrgId);
  344. this.$message.success("操作成功!");
  345. });
  346. }
  347. },
  348. //新增联系方式
  349. addMethod() {
  350. this.customerOrg.contactMethodList.push({
  351. contactMethodValue: "",
  352. contactMethodType: "0",
  353. contactPersonId: this.personId,
  354. });
  355. },
  356. rowClick(row) {
  357. console.log("row", row);
  358. // this.$message.success("rowClick");
  359. this.form = row;
  360. this.personId = row.id;
  361. this.getContactMethodList(row.id);
  362. },
  363. rowClickMethod(row) {
  364. this.$message.success("rowClickMethod");
  365. },
  366. },
  367. };
  368. </script>
  369. <style scoped></style>