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.

672 lines
24 KiB

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