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.

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