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.

697 lines
26 KiB

3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
5 months ago
2 years ago
2 years ago
5 months ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
5 months 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
5 months ago
5 months ago
4 months ago
2 years ago
5 months ago
3 years ago
5 months ago
3 years ago
3 years ago
4 months ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
5 months ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
5 months 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
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
5 months ago
5 months ago
5 months ago
4 months ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
5 months ago
3 years ago
2 years ago
3 years ago
5 months ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
5 months ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
5 months ago
5 months ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 months ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
5 months ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
5 months ago
2 years ago
5 months ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 months ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
5 months ago
5 months ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
5 months ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 months ago
2 years ago
2 years ago
2 years ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
5 months ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div style="display: flex">
  3. <div :style="'margin-left: 5px;width:' + (window.pageWidth - 200 - 110 - 20) + 'px;'">
  4. <!--overflow-y: scroll;height:200px;-->
  5. <el-form ref="form" :model="form" label-width="85px" :rules="rules" size="medium">
  6. <el-row>
  7. <el-col :span="8">
  8. <el-form-item label="上级单位" prop="parentId">
  9. <el-cascader v-model="form.parentId" :options="customerOrg.customerOrgTree"
  10. :props="{ checkStrictly: true, expandTrigger: 'hover', ...customerOrg.treeprops, }"
  11. :show-all-levels="false" clearable filterable disabled
  12. :style="'width:' + Math.floor((window.pageWidth - 585) / 3) + 'px;'">
  13. </el-cascader>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="8">
  17. <el-form-item label="单位名称" prop="displayName">
  18. <el-input class="enterToTab" v-model="form.displayName" placeholder="请输入单位名称"
  19. :disabled="customerOrg.oprStatus ? false : true" />
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="4">
  23. <el-form-item label="单位简称" prop="shortName">
  24. <el-input class="enterToTab" v-model="form.shortName" placeholder="请输入单位简称"
  25. :disabled="customerOrg.oprStatus ? false : true" />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="2">
  29. <el-form-item label="加锁" prop="isLock" label-width="56px">
  30. <!--
  31. <el-radio v-model="form.isLock" label="Y" ></el-radio>
  32. <el-radio v-model="form.isLock" label="N" ></el-radio>
  33. -->
  34. <el-checkbox v-model="form.isLock" true-label="Y" false-label="N" />
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="2">
  38. <el-form-item label="启用" prop="isActive" label-width="56px">
  39. <!--
  40. <el-radio v-model="form.isActive" label="Y">启用</el-radio>
  41. <el-radio v-model="form.isActive" label="N">停用</el-radio>
  42. -->
  43. <el-checkbox v-model="form.isActive" true-label="Y" false-label="N" />
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. <el-row>
  48. <el-col :span="8">
  49. <el-form-item label="体检中心" prop="medicalCenterId">
  50. <el-select v-model="form.medicalCenterId" placeholder="请选择" filterable :disabled="peisid ? true : false"
  51. :style="'width:' + Math.floor((window.pageWidth - 585) / 3) + 'px;'">
  52. <el-option v-for="item in data.organizationdata" :key="item.id" :label="item.displayName"
  53. :value="item.id" />
  54. </el-select>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="8">
  58. <el-form-item label="单位性质" prop="orgTypeId">
  59. <el-select class="enterToTab" v-model="form.orgTypeId" placeholder="请选择" filterable
  60. :style="'width:' + Math.floor((window.pageWidth - 585) / 3) + 'px;'">
  61. <el-option v-for="item in data.customerOrgType" :key="item.id" :label="item.displayName"
  62. :value="item.id" />
  63. </el-select>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="8">
  67. <el-form-item label="体检类别" prop="medicalTypeId">
  68. <el-select v-model="form.medicalTypeId" placeholder="请选择" filterable clearable
  69. :style="'width:' + Math.floor((window.pageWidth - 585) / 3) + 'px;'" size="small">
  70. <el-option v-for="item in dict.medicalType" :key="item.id" :label="item.displayName" :value="item.id" />
  71. </el-select>
  72. </el-form-item>
  73. </el-col>
  74. <!--
  75. <el-form-item label="显示顺序" prop="displayOrder">
  76. <el-input type="number" v-model="form.displayOrder" />
  77. </el-form-item>
  78. -->
  79. <!--
  80. <el-form-item label="单位简码" prop="simpleCode">
  81. <el-input v-model="form.simpleCode" placeholder="由系统自动生成" disabled />
  82. </el-form-item>
  83. -->
  84. </el-row>
  85. <el-row>
  86. <el-col :span="8">
  87. <el-form-item label="人员类别" prop="personnelTypeId">
  88. <el-select v-model="form.personnelTypeId" placeholder="请选择" filterable clearable
  89. :style="'width:' + Math.floor((window.pageWidth - 585) / 3) + 'px;'" size="small">
  90. <el-option v-for="item in dict.personnelType" :key="item.id" :label="item.displayName" :value="item.id" />
  91. </el-select>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="4">
  95. <el-form-item label="联系电话" prop="telephone">
  96. <el-input class="enterToTab" v-model="form.telephone" placeholder="请输入联系电话" />
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="4">
  100. <el-form-item label="传真" prop="fax">
  101. <el-input class="enterToTab" v-model="form.fax" placeholder="请输入传真" />
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="4">
  105. <el-form-item label="邮政编码" prop="postalCode">
  106. <el-input class="enterToTab" v-model="form.postalCode" placeholder="请输入邮政编码" />
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="4">
  110. <el-form-item label="常用单位" prop="isRecommend">
  111. <el-checkbox v-model="form.isRecommend" true-label="Y" false-label="N" />
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. <el-row>
  116. <el-col :span="8">
  117. <el-form-item label="发票抬头" prop="invoiceName">
  118. <el-input class="enterToTab" v-model="form.invoiceName" placeholder="请输入发票抬头" />
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="8">
  122. <el-form-item label="开户银行" prop="bank">
  123. <el-input class="enterToTab" v-model="form.bank" placeholder="请输入开户银行" />
  124. </el-form-item>
  125. </el-col>
  126. <el-col :span="8">
  127. <el-form-item label="银行账号" prop="accounts">
  128. <el-input class="enterToTab" v-model="form.accounts" placeholder="请输入银行账号" />
  129. </el-form-item>
  130. </el-col>
  131. </el-row>
  132. <el-row>
  133. <el-col :span="8">
  134. <el-form-item label="地址" prop="address">
  135. <el-input class="enterToTab" v-model="form.address" placeholder="请输入地址" maxlength="50" show-word-limit />
  136. </el-form-item>
  137. </el-col>
  138. <el-col :span="8">
  139. <el-form-item label="税号" prop="countryOrgCode">
  140. <el-input v-model="form.countryOrgCode" />
  141. </el-form-item>
  142. </el-col>
  143. <el-col :span="8">
  144. <el-form-item label="备注" prop="remark">
  145. <el-input class="enterToTab" v-model="form.remark" maxlength="100" show-word-limit />
  146. </el-form-item>
  147. </el-col>
  148. </el-row>
  149. <el-row>
  150. <el-col :span="8">
  151. <el-form-item label="编号" prop="id">
  152. <el-input v-model="form.id" disabled />
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="8">
  156. <el-form-item label="介绍人" prop="salesPerson">
  157. <el-input v-model="form.salesPerson" />
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="8">
  161. <el-form-item label="介绍人电话" prop="salesPersonPhone">
  162. <el-input v-model="form.salesPersonPhone" />
  163. </el-form-item>
  164. </el-col>
  165. </el-row>
  166. <el-row>
  167. <el-col :span="5">
  168. <el-form-item label="创建人员">
  169. <el-input v-model="form.creatorName" size="small" disabled />
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="7">
  173. <el-form-item label="创建时间">
  174. <el-date-picker v-model="form.creationTime" type="datetime" size="small" style="width: 100%" disabled />
  175. </el-form-item>
  176. </el-col>
  177. <el-col :span="5">
  178. <el-form-item label="修改人员">
  179. <el-input v-model="form.lastModifierName" size="small" disabled />
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="7">
  183. <el-form-item label="修改时间">
  184. <el-date-picker v-model="form.lastModificationTime" type="datetime" size="small" style="width: 100%"
  185. disabled />
  186. </el-form-item>
  187. </el-col>
  188. </el-row>
  189. </el-form>
  190. </div>
  191. <!-- 按钮区域 -->
  192. <div style="width: 110px; margin-left: 10px; margin-top: 3%">
  193. <div v-show="checkPagePriv(pagePriv.privs, '新增单位')" class="btnList">
  194. <el-button type="primary" @click="btnAdd('form', '')" class="commonbutton">新增单位</el-button>
  195. </div>
  196. <div v-show="checkPagePriv(pagePriv.privs, '新增子单位')" class="btnList">
  197. <el-button type="primary" @click="btnAdd('form', 'child')" class="commonbutton">新增子单位</el-button>
  198. </div>
  199. <div class="btnList">
  200. <el-button type="primary" @click="btnAdd('form', 'newCopy')" class="commonbutton">复制新增</el-button>
  201. </div>
  202. <div v-show="checkPagePriv(pagePriv.privs, '保存')" class="btnList">
  203. <el-button type="success" @click="btnSubmit('form')" class="commonbutton"><i
  204. class="el-icon-check"></i>保存</el-button>
  205. </div>
  206. <div v-show="checkPagePriv(pagePriv.privs, '删除')" class="btnList">
  207. <el-button type="danger" @click="btnDel('form')" class="deleteButton">
  208. <i class="el-icon-delete"></i>删除
  209. </el-button>
  210. </div>
  211. </div>
  212. </div>
  213. </template>
  214. <script>
  215. import { mapState, mapMutations } from "vuex";
  216. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  217. import { getPagePriv, checkPagePriv, tcdate, objCopy, deepCopy, arrayExistObj } from "../../utlis/proFunc";
  218. import { getTreeNode, getTreePids } from "../../utlis/tree";
  219. export default {
  220. components: {},
  221. props: ["id"],
  222. data() {
  223. return {
  224. pagePriv: {
  225. routeUrlorPageName: 'customerOrg', //当前页面归属路由或归属页面权限名称
  226. privs: [] // 页面权限
  227. },
  228. customerOrgEditStyle: "height:400px;",
  229. data: {
  230. organizationdata: [], //体检中心数据
  231. customerOrgType: [], //单位类别
  232. },
  233. peisid: null,
  234. form: {
  235. id: "",
  236. displayName: "",
  237. shortName: "",
  238. invoiceName: "",
  239. parentId: null,
  240. telephone: "",
  241. fax: "",
  242. postalCode: "",
  243. address: "",
  244. bank: "",
  245. countryOrgCode: "",
  246. accounts: "",
  247. orgTypeId: null,
  248. remark: "",
  249. isLock: "N",
  250. isActive: "Y",
  251. medicalCenterId: null,
  252. creatorName: "",
  253. creationTime: null,
  254. lastModifierName: "",
  255. lastModificationTime: null,
  256. salesPerson: "",
  257. salesPersonPhone: "",
  258. medicalTypeId:'',
  259. personnelTypeId:'',
  260. isRecommend:'N',
  261. }, //初始化 单位 记录 目前新增与更新是一致
  262. formInit: {},
  263. rules: {
  264. displayName: [{ required: true, message: "请输入单位名称", trigger: "blur" }],
  265. shortName: [{ required: true, message: "请输入单位简写", trigger: "blur" }],
  266. orgTypeId: [{ required: true, message: "请输入单位性质", trigger: "blur" }],
  267. medicalCenterId: [
  268. { required: true, message: "请输入体检中心", trigger: "blur" },
  269. ],
  270. },
  271. isshow: false,
  272. };
  273. },
  274. created() {
  275. //获取用户当前页面的权限
  276. let userPriv = window.sessionStorage.getItem('userPriv')
  277. if (userPriv) this.pagePriv.privs = deepCopy(getPagePriv(this.pagePriv.routeUrlorPageName))
  278. this.peisid = window.sessionStorage.getItem("peisid");
  279. if (!this.form.id) {
  280. this.form.medicalCenterId = this.peisid;
  281. }
  282. this.formInit = deepCopy(this.form)
  283. },
  284. //挂载完成
  285. mounted() {
  286. // 表单中 回车 代替 tab
  287. this.enterToTab();
  288. // 初始化 字典数据
  289. this.dictInit()
  290. this.getCustomerOrgRd(this.dataTransOpts.tableS.customer_org.id);
  291. },
  292. computed: {
  293. ...mapState(["customerOrg", "dict", "window", "dataTransOpts"]),
  294. },
  295. methods: {
  296. ...mapMutations(["setData"]), checkPagePriv,
  297. // changeBox(type) {
  298. // //赋值
  299. // if (this.form[type + "Box"]) {
  300. // this.form[type] = "Y";
  301. // } else {
  302. // this.form[type] = "N";
  303. // }
  304. // },
  305. //获取单位信息
  306. getCustomerOrgRd(id) {
  307. if (!id) {
  308. this.form = deepCopy(this.formInit)
  309. return;
  310. }
  311. getapi(`/api/app/customer-org/${id}`).then((res) => {
  312. if (res.code != -1) {
  313. this.dataTransOpts.tableS.customer_org.id = res.data.id
  314. objCopy(res.data, this.form);
  315. // if (res.data.isActive == "Y") {
  316. // this.form.isActiveBox = true;
  317. // } else {
  318. // this.form.isActiveBox = false;
  319. // }
  320. // if (res.data.isLock == "Y") {
  321. // this.form.isLockBox = true;
  322. // } else {
  323. // this.form.isLockBox = false;
  324. // }
  325. }
  326. });
  327. },
  328. // 初始化 字典数据
  329. dictInit() {
  330. //获取组织体检中心数据
  331. getapi("/api/app/organization-units/organization-unit-by-is-peis").then((res) => {
  332. this.data.organizationdata = res.data;
  333. });
  334. //获取单位类别列表
  335. getapi("/api/app/customer-org-type/get-all").then((res) => {
  336. this.data.customerOrgType = res.data;
  337. });
  338. //体检类别
  339. getapi("/api/app/medical-type/in-filter").then((res) => {
  340. if (res.code > -1) {
  341. this.dict.medicalType = res.data;
  342. }
  343. });
  344. //人员类别
  345. getapi("/api/app/personnel-type/in-filter").then((res) => {
  346. if (res.code > -1) {
  347. this.dict.personnelType = res.data;
  348. }
  349. });
  350. },
  351. //更新获取单位树节点数据(局部刷新)
  352. getCustomerOrgTree(oprType, body) {
  353. // getapi("/api/app/customerorg/getbycodeall").then((res) => {
  354. // //customerOrgTree = res.data;
  355. // console.log("res.data", res.data);
  356. // this.setData({ key: "customerOrg.customerOrgTree", value: res.data });
  357. // tcdate(this.customerOrg.customerOrgTree);
  358. // });
  359. switch (oprType) {
  360. case "insert":
  361. let node = {
  362. id: body.id,
  363. displayName: body.displayName,
  364. label: (body.customerOrgCode ? body.customerOrgCode + ' ' : '') + body.displayName,
  365. parentId: body.parentId,
  366. };
  367. if (body.parentId) {
  368. let pNode = getTreeNode(this.customerOrg.customerOrgTree, "treeChildren", "id", body.parentId);
  369. if (!pNode.treeChildren) this.$set(pNode, 'treeChildren', []);
  370. //pNode.treeChildren = []
  371. pNode.treeChildren.push(node);
  372. } else {
  373. this.customerOrg.customerOrgTree.push(node);
  374. }
  375. this.customerOrg.defaultExpandedKeys = []
  376. if (body.parentId) {
  377. this.customerOrg.defaultExpandedKeys.push(body.parentId)
  378. }
  379. this.customerOrg.defaultExpandedKeys.push(body.id)
  380. this.customerOrg.treeCurrentNodekey = body.id;
  381. //console.log("this.customerOrg.treeCurrentNodekey",this.customerOrg.treeCurrentNodekey);
  382. break;
  383. // "id": "3a0c5101-a6a6-e48a-36ec-33e7567a99e6",
  384. // "displayName": "神豚集团",
  385. // "parentId": null,
  386. // "code": "00001",
  387. // "treeChildren": [
  388. case "update":
  389. let node2 = getTreeNode(
  390. this.customerOrg.customerOrgTree,
  391. "treeChildren",
  392. "id",
  393. body.id
  394. );
  395. node2.displayName = body.displayName;
  396. node2.label = (body.customerOrgCode ? body.customerOrgCode + ' ' : '') + body.displayName
  397. break;
  398. case "delete":
  399. let lfind = -1;
  400. let pids = getTreePids(
  401. this.customerOrg.customerOrgTree,
  402. "treeChildren",
  403. "parentId",
  404. "id",
  405. body
  406. );
  407. //tree, childNodeName, pidName, idName, idVal getTreeNode(this.customerOrg.customerOrgTree, "treeChildren", "id", body);
  408. console.log('pids', pids, body)
  409. // 顶级节点
  410. if (!pids || pids.length < 2) {
  411. lfind = arrayExistObj(this.customerOrg.customerOrgTree, "id", body);
  412. if (lfind > -1) this.customerOrg.customerOrgTree.splice(lfind, 1);
  413. } else {
  414. // 非顶级节点
  415. let node3 = getTreeNode(
  416. this.customerOrg.customerOrgTree,
  417. "treeChildren",
  418. "id",
  419. pids[pids.length - 1]
  420. );
  421. //console.log('node3',node3)
  422. if (node3) {
  423. lfind = arrayExistObj(node3.treeChildren, "id", body);
  424. if (lfind > -1) node3.treeChildren.splice(lfind, 1);
  425. }
  426. }
  427. break;
  428. default:
  429. break;
  430. }
  431. },
  432. onkeyup(e) {
  433. console.log('onkeyup e', e)
  434. },
  435. //提交
  436. btnSubmit(formName) {
  437. let body = {};
  438. console.log("vuex data", this.customerOrg.customerOrgRd);
  439. this.$refs[formName].validate((valid, fields) => {
  440. if (!valid) {
  441. this.$message.warning({ showClose: true, message: fields[Object.keys(fields)[0]][0].message });
  442. return false;
  443. }
  444. body = deepCopy(this.form);
  445. delete body.isActiveBox;
  446. delete body.isLockBox;
  447. delete body.creatorName;
  448. delete body.creationTime;
  449. delete body.lastModifierName;
  450. delete body.lastModificationTime;
  451. if (typeof body.parentId === "string") {
  452. if (!body.parentId || body.parentId.length < 1) {
  453. body.parentId = null;
  454. }
  455. } else {
  456. if (body.parentId && body.parentId.length > 0) {
  457. body.parentId = body.parentId[body.parentId.length - 1];
  458. } else {
  459. body.parentId = null;
  460. }
  461. }
  462. if(!body.medicalTypeId) delete body.medicalTypeId;
  463. if(!body.personnelTypeId) delete body.personnelTypeId;
  464. console.log("body", body, "this.form", this.form);
  465. if (!this.form.id) {
  466. //id为空则新增
  467. postapi(`/api/app/customerorg/create`, body).then(async (res) => {
  468. if (res.code == 1) {
  469. this.$message.success({ showClose: true, message: '操作成功!' })
  470. //console.log("创健 操作成功");
  471. //this.setData({ key: "customerOrg.customerOrgRd", value: res });
  472. this.form = res.data
  473. this.dataTransOpts.tableS.customer_org = res.data
  474. // this.customerOrg.customerOrgId = res.data.id;
  475. this.customerOrg.customerOrgRd = res.data;
  476. this.getCustomerOrgTree("insert", res.data);
  477. this.customerOrg.oprStatus = 'edit'
  478. this.dataTransOpts.tableS.customer_org.parent_id = await this.getParentCustomerOrgId(res.data.id)
  479. this.dataTransOpts.refresh.customer_org.S++
  480. this.dataTransOpts.refresh.customer_org_register.M++
  481. this.dataTransOpts.refresh.contact_person.M++
  482. }
  483. });
  484. } else {
  485. //id不为空则编辑
  486. putapi(`/api/app/customer-org/${this.form.id}`, body).then(
  487. (res) => {
  488. if (res.code == 1) {
  489. this.$message.success({ showClose: true, message: '操作成功!' })
  490. let lbody = { ...deepCopy(body), id: this.form.id };
  491. this.getCustomerOrgTree("update", lbody);
  492. this.customerOrg.oprStatus = 'edit'
  493. this.dataTransOpts.refresh.customer_org.S++
  494. this.dataTransOpts.refresh.customer_org_register.M++
  495. this.dataTransOpts.refresh.contact_person.M++
  496. }
  497. }
  498. );
  499. }
  500. });
  501. },
  502. // 获取顶级单位ID
  503. async getParentCustomerOrgId(customerOrgId) {
  504. let customerOrgParentId = null
  505. if (!customerOrgId) return customerOrgParentId
  506. if (typeof customerOrgId == 'string') {
  507. try {
  508. let res = await getapi(`/api/app/customer-org/parent/${customerOrgId}`)
  509. if (res.code != -1) customerOrgParentId = res.data
  510. } catch (error) {
  511. console.log('获取顶级单位ID出错:', error)
  512. }
  513. } else if (customerOrgId.length > 0) {
  514. customerOrgParentId = customerOrgId[0]
  515. }
  516. return customerOrgParentId
  517. },
  518. //新增弹框
  519. async btnAdd(formName, child) {
  520. switch (child) {
  521. case 'newCopy':
  522. if (!this.form.id) return
  523. //let copyForm = deepCopy(this.form)
  524. //this.from = deepCopy(copyForm)
  525. this.form.displayName = ''
  526. this.form.shortName = ''
  527. this.form.id = ''
  528. this.$message.warning({ showClose: true, message: '复制新增,请记得要点击【保存】!' })
  529. break;
  530. default:
  531. let formPre = deepCopy(this.form)
  532. await this.$refs[formName].resetFields();
  533. //console.log('this.peisid',this.peisid)
  534. if (!this.peisid || this.peisid == 'null') {
  535. this.$message.warning({ showClose: true, message: "该用户未选归属体检中心,不能执行此操作!" });
  536. return
  537. }
  538. this.form = deepCopy(this.formInit)
  539. if (child) {
  540. if (!this.dataTransOpts.tableS.customer_org.id) {
  541. this.$message.warning({ showClose: true, message: "请先选择上级单位" });
  542. this.customerOrg.oprStatus = ''
  543. return;
  544. }
  545. this.form.parentId = this.dataTransOpts.tableS.customer_org.id
  546. this.form.orgTypeId = formPre.orgTypeId
  547. } else {
  548. // 新增一级单位时,清除 vuex 一级单位ID
  549. this.dataTransOpts.tableS.customer_org.parent_id = ''
  550. }
  551. break;
  552. }
  553. this.customerOrg.oprStatus = 'add'
  554. // this.customerOrg.customerOrgId = "";
  555. this.dataTransOpts.tableS.customer_org.id = ''
  556. setTimeout(() => {
  557. this.dataTransOpts.refresh.customer_org_register.M++
  558. this.dataTransOpts.refresh.contact_person.M++
  559. }, 20);
  560. },
  561. //删除
  562. btnDel(formName) {
  563. if (!this.dataTransOpts.tableS.customer_org.id) {
  564. this.$message.warning({ showClose: true, message: "请先选中要删除的节点" })
  565. return
  566. }
  567. //复制待删除的节点
  568. //let node = deepCopy(getTreeNode(this.customerOrg.customerOrgTree,"treeChildren","id",this.customerOrg.customerOrgRd.id));
  569. this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
  570. confirmButtonText: "是",
  571. cancelButtonText: "否",
  572. type: "warning",
  573. }).then(() => {
  574. //console.log('{patientRegisterIds}',{patientRegisterIds})
  575. return deletapi(`/api/app/customer-org/${this.dataTransOpts.tableS.customer_org.id}`);
  576. }).then((res) => {
  577. if (res.code != -1) {
  578. //console.log("删除 操作成功");
  579. this.getCustomerOrgTree("delete", this.dataTransOpts.tableS.customer_org.id);
  580. this.customerOrg.customerOrgRegisterList = []
  581. this.customerOrg.contactPersonList = []
  582. this.customerOrg.contactMethodList = []
  583. this.setData({ key: "customerOrg.customerOrgRd", value: { id: "" } });
  584. this.$refs[formName].resetFields();
  585. this.customerOrg.oprStatus = ''
  586. // this.customerOrg.customerOrgId = ''
  587. this.dataTransOpts.tableS.customer_org.id = ''
  588. }
  589. }).catch((err) => {
  590. if (err == "cancel") {
  591. this.$message.info({ showClose: true, message: "已取消删除" });
  592. } else {
  593. this.$message.error({ showClose: true, message: "操作失败,原因:" + err });
  594. }
  595. });
  596. },
  597. //回车替代tab键
  598. enterToTab() {
  599. this.$nextTick(() => {
  600. let inputs = document.querySelectorAll("form input"); //用数组可以读取多个标签的元素 //.inline-input
  601. //console.log('inputs',inputs);
  602. // 为每个输入框添加键盘事件监听器
  603. inputs.forEach((input, i) => {
  604. input.addEventListener('keydown', (event) => {
  605. // 如果按下的是回车键
  606. // console.log('data-ismultiline',input.getAttribute('data-ismultiline'));
  607. if (event.keyCode === 13) {
  608. // 阻止回车键的默认行为(换行)
  609. event.preventDefault();
  610. // 跳至下一个输入框
  611. for (let j = i + 1; j < inputs.length; j++) {
  612. if (inputs[j].getAttribute('disabled') != "disabled") {
  613. inputs[j].focus();
  614. break;
  615. }
  616. }
  617. }
  618. });
  619. });
  620. });
  621. },
  622. },
  623. watch: {
  624. // 单位id未变时,强制刷新
  625. "dataTransOpts.refresh.customer_org.S": {
  626. // immediate: true,
  627. handler(newVal, oldVal) {
  628. console.log(`watch 体检单位 newVal:${newVal} oldVal:${oldVal} customerOrgId: ${this.dataTransOpts.tableS.customer_org.id}`);
  629. this.getCustomerOrgRd(this.dataTransOpts.tableS.customer_org.id);
  630. }
  631. },
  632. },
  633. };
  634. </script>
  635. <style scoped>
  636. @import "../../assets/css/global_form.css";
  637. @import "../../assets/css/global_button.css";
  638. .btnList {
  639. margin-bottom: 10px;
  640. }
  641. .btnClass {
  642. width: 110px;
  643. }
  644. </style>