Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

addSupply.vue 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="dialogVisible"
  5. width="40%"
  6. :before-close="closePop"
  7. >
  8. <!-- :before-close="handleClose" 如需要可添加进上方 -->
  9. <div>
  10. <el-form
  11. :inline="true"
  12. :model="supplier"
  13. class="demo-form-inline"
  14. label-width="100px"
  15. :rules="rules"
  16. ref="supplier"
  17. >
  18. <el-row>
  19. <el-col :span="6">
  20. <el-form-item label="供应商编码" prop="supplierCode">
  21. <el-input v-model="supplier.supplierCode"></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="6">
  25. <el-form-item label="供应商名称" prop="supplierName">
  26. <el-input v-model="supplier.supplierName"></el-input>
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. <el-row>
  31. <el-col :span="6">
  32. <el-form-item label="供应商类别" prop="supplierType">
  33. <!-- <el-input v-model="supplier.type"></el-input> -->
  34. <!-- <el-autocomplete
  35. v-model="supplier.supplierType"
  36. :fetch-suggestions="querySearchAsync"
  37. @select="handleSelect"
  38. ></el-autocomplete> -->
  39. <el-select v-model="supplier.supplierType" @select="handleSelect">
  40. <el-option
  41. v-for="item in supplierType"
  42. :key="item.name"
  43. :label="item.name"
  44. :value="item.value"
  45. >
  46. </el-option>
  47. </el-select>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="6">
  51. <el-form-item label="增值税税率" prop="vatRate">
  52. <el-input
  53. v-model="supplier.vatRate"
  54. @keyup.native="supplier.vatRate = oninput(supplier.vatRate)"
  55. ></el-input
  56. >%
  57. </el-form-item>
  58. </el-col>
  59. </el-row>
  60. <el-row>
  61. <el-col :span="6">
  62. <el-form-item label="纳税人识别号" prop="number">
  63. <el-input v-model="supplier.number"></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="6">
  67. <el-form-item label="开户银行" prop="bank">
  68. <el-input v-model="supplier.bank"></el-input>
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. <el-row>
  73. <el-col :span="6">
  74. <el-form-item label="银行账号" prop="bankAccount">
  75. <el-input v-model="supplier.bankAccount"></el-input>
  76. </el-form-item>
  77. </el-col>
  78. </el-row>
  79. </el-form>
  80. <el-form :model="recordInfo" ref="recordInfo" class="tableclass">
  81. <el-table
  82. :row-style="{ color: '#303133' }"
  83. :header-cell-style="{
  84. backgroundColor: 'rgb(245, 247, 250)',
  85. color: '#606266',
  86. }"
  87. :data="recordInfo.contacts"
  88. :class="signAndWeighBoxPatients"
  89. border
  90. style="width: 100%"
  91. max-height="450"
  92. >
  93. <!-- 联系人填写 -->
  94. <el-table-column label="联系人" align="center" width="130">
  95. <template slot="header" slot-scope="scope">
  96. <span>联系人</span>
  97. </template>
  98. <!-- tableRules.name -->
  99. <template slot-scope="scope">
  100. <el-form-item
  101. :prop="'contacts.' + scope.$index + '.name'"
  102. :rules="
  103. scope.row.name == ''
  104. ? [
  105. {
  106. required: 'true',
  107. message: '请输入主要联系人',
  108. trigger: ['blur'],
  109. },
  110. ]
  111. : null
  112. "
  113. >
  114. <el-input
  115. v-model="scope.row.name"
  116. style="width: 100px; margin-top: 3px"
  117. ></el-input>
  118. </el-form-item>
  119. </template>
  120. </el-table-column>
  121. <!-- 手机填写 -->
  122. <el-table-column label="手机" align="center" width="150">
  123. <template slot-scope="scope">
  124. <el-input
  125. v-model="scope.row.phone"
  126. style="width: 120px"
  127. ></el-input>
  128. <div style="visibility: hidden">/</div>
  129. </template>
  130. </el-table-column>
  131. <!-- id填写======================================================= -->
  132. <el-table-column label="id" v-if="false">
  133. <template slot-scope="scope">
  134. <el-input v-model="scope.row.id" style="width: 100px"></el-input>
  135. <div style="visibility: hidden">/</div>
  136. </template>
  137. </el-table-column>
  138. <!-- 联系地址填写 -->
  139. <el-table-column label="联系地址" align="center" width="150">
  140. <template slot-scope="scope">
  141. <el-input
  142. v-model="scope.row.address"
  143. style="width: 120px"
  144. ></el-input>
  145. <div style="visibility: hidden">/</div>
  146. </template>
  147. </el-table-column>
  148. <!-- 首要联系人填写 -->
  149. <el-table-column align="center" width="130px">
  150. <template slot="header" slot-scope="scope">
  151. <span>首要联系人<span style="color: red">*</span></span>
  152. </template>
  153. <template slot-scope="scope">
  154. <el-form-item :prop="'contacts.' + scope.$index + '.name'">
  155. <!-- :prop="'contacts.' + scope.$index + '.name'" 如需添加可在上方标签加入 -->
  156. <el-select
  157. v-model="scope.row.is_first"
  158. style="width: 110px"
  159. @change="changeName($event, scope)"
  160. >
  161. <el-option
  162. v-for="(item, index) in tabList"
  163. :key="index"
  164. :label="item.label"
  165. :value="item.value"
  166. >
  167. </el-option>
  168. </el-select>
  169. </el-form-item>
  170. </template>
  171. </el-table-column>
  172. <el-table-column
  173. label="操作"
  174. align="center"
  175. width="150px"
  176. fixed="right"
  177. >
  178. <template slot-scope="scope">
  179. <el-tooltip
  180. class="item"
  181. effect="dark"
  182. content="新增"
  183. placement="top"
  184. >
  185. <el-button
  186. size="mini"
  187. type="primary"
  188. icon="el-icon-circle-plus-outline"
  189. @click="handleAdd(scope.$index, scope.row)"
  190. >
  191. </el-button>
  192. </el-tooltip>
  193. <el-tooltip
  194. class="item"
  195. effect="dark"
  196. content="删除"
  197. placement="top"
  198. >
  199. <el-button
  200. size="mini"
  201. type="danger"
  202. icon="el-icon-delete"
  203. @click="handleDelete(scope.$index, scope.row)"
  204. >
  205. </el-button>
  206. </el-tooltip>
  207. </template>
  208. </el-table-column>
  209. </el-table>
  210. </el-form>
  211. </div>
  212. <span slot="footer" class="dialog-footer">
  213. <el-button @click="closePop">取 消</el-button>
  214. <el-button type="primary" @click="submitForm('supplier', 'recordInfo')"
  215. >确 定</el-button
  216. >
  217. </span>
  218. </el-dialog>
  219. </template>
  220. <script>
  221. import {
  222. getSupplierId,
  223. getsupplytype,
  224. getsupplyandcontactone,
  225. delcontactone,
  226. savesupply,
  227. updatesupply,
  228. getexporthistory,
  229. } from "@/api/supply";
  230. import Template from "../../data/template.vue";
  231. export default {
  232. data() {
  233. return {
  234. show_type: 1,
  235. supplier_ids: "",
  236. title: "",
  237. Template,
  238. supplierType: [],
  239. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  240. list: ["001", "002"],
  241. // 表单验证规则
  242. rules: {
  243. supplierCode: [
  244. {
  245. required: true,
  246. message: "请填写供应商编号",
  247. trigger: "blur",
  248. },
  249. ],
  250. supplierName: [
  251. {
  252. required: true,
  253. message: "请填写供应商名称",
  254. trigger: "blur",
  255. },
  256. ],
  257. },
  258. tabList: [
  259. {
  260. value: 1,
  261. label: "是",
  262. },
  263. {
  264. value: 0,
  265. label: "否",
  266. },
  267. ],
  268. tableRules: {
  269. name: [{ required: true, message: "联系人不能为空", trigger: "blur" }],
  270. },
  271. recordInfo: {
  272. contacts: [{}],
  273. },
  274. tableData: [
  275. {
  276. id: "",
  277. contacts: "",
  278. phone: "",
  279. address: "",
  280. FirstConcats: "",
  281. operate: "",
  282. },
  283. ],
  284. dialogVisible: false,
  285. supplier: {
  286. supplierName: "",
  287. supplierCode: "gsy001",
  288. supplierType: "",
  289. vatRate: 0,
  290. number: "",
  291. bank: "",
  292. bankAccount: "",
  293. },
  294. supply_code: [],
  295. select_supply: [],
  296. type: "",
  297. timeout: null,
  298. id: "",
  299. name: "",
  300. };
  301. },
  302. created() {},
  303. methods: {
  304. show(data, type) {
  305. if (type == 1) {
  306. this.initSupplierData();
  307. this.show_type = 1;
  308. this.title = "新增供应商";
  309. this.getsupplytype();
  310. this.dialogVisible = true;
  311. } else if (type == 2) {
  312. this.getsupplytype();
  313. // console.log(data,'oop')
  314. this.show_type = 2;
  315. this.supplier_ids = data.ID;
  316. this.title = "编辑供应商";
  317. this.supplier.supplierCode = data.SupplierCode;
  318. this.supplier.supplierName = data.SupplierName;
  319. if (data.SupplierType == 0) {
  320. this.supplier.supplierType = "";
  321. } else {
  322. this.supplier.supplierType = data.SupplierType;
  323. }
  324. this.supplier.vatRate = data.VatRate;
  325. this.supplier.number = data.Number;
  326. this.supplier.bank = data.Bank;
  327. this.supplier.bankAccount = data.BankAccount;
  328. this.getcontacts(data.ID);
  329. this.dialogVisible = true;
  330. }
  331. },
  332. oninput(num) {
  333. var str = num;
  334. var len1 = str.substr(0, 1);
  335. var len2 = str.substr(1, 1);
  336. //如果第一位是0,第二位不是点,就用数字把点替换掉
  337. if (str.length > 1 && len1 == 0 && len2 != ".") {
  338. str = str.substr(1, 1);
  339. }
  340. //第一位不能是.
  341. if (len1 == ".") {
  342. str = "";
  343. }
  344. //限制只能输入一个小数点
  345. if (str.indexOf(".") != -1) {
  346. var str_ = str.substr(str.indexOf(".") + 1);
  347. if (str_.indexOf(".") != -1) {
  348. str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
  349. }
  350. }
  351. //正则替换
  352. str = str.replace(/[^\d^\.]+/g, ""); // 保留数字和小数点
  353. str = str.replace(/\.\d\d\d\d$/, ""); // 小数点后只能输两位
  354. return str;
  355. },
  356. closePop() {
  357. this.dialogVisible = false;
  358. this.supply_code = [];
  359. this.supplier.supplierCode = "";
  360. this.supplier.supplierName = "";
  361. this.supplier.supplierType = "";
  362. this.supplier.vatRate = "";
  363. this.supplier.number = "";
  364. this.supplier.bank = "";
  365. this.supplier.bankAccount = "";
  366. this.recordInfo.contacts = [{}];
  367. },
  368. // 获取供应商编码接口
  369. initSupplierData() {
  370. getSupplierId().then((res) => {
  371. if (res.data.state == 1) {
  372. this.supplier.supplierCode =
  373. res.data.data.supplycode[0].supplier_code;
  374. }
  375. });
  376. },
  377. getsupplytype() {
  378. // 获取供应商类别接口
  379. getsupplytype()
  380. .then((res) => {
  381. if (res.status == 200) {
  382. this.supplierType = res.data.data.list;
  383. }
  384. })
  385. .catch((err) => {
  386. console.log(err);
  387. });
  388. },
  389. handleSelect(item) {
  390. this.supplier.name = item.value;
  391. this.supplier.value = item.name;
  392. },
  393. // 验证表单内容
  394. submitForm(supplier, formName) {
  395. if (this.show_type == 1) {
  396. this.$refs[supplier].validate((valid) => {
  397. if (valid) {
  398. this.$refs[formName].validate((valid) => {
  399. if (valid) {
  400. this.recordInfo.contacts.forEach((el) => {
  401. if (!el.phone) {
  402. el.phone = "";
  403. }
  404. if (!el.address) {
  405. el.address = "";
  406. }
  407. if (!el.id) {
  408. el.id = 0;
  409. }
  410. });
  411. let params = {
  412. suppliercode: this.supplier.supplierCode || "",
  413. suppliername: this.supplier.supplierName || "",
  414. suppliertype: this.supplier.supplierType || 0,
  415. vatrate: this.supplier.vatRate || 0,
  416. number: this.supplier.number || "",
  417. bank: this.supplier.bank || "",
  418. bankaccount: this.supplier.bankAccount || "",
  419. contacts: [...this.recordInfo.contacts],
  420. };
  421. savesupply(params).then((res) => {
  422. if (res.data.state == 1) {
  423. this.$message.success("新增成功");
  424. this.closePop();
  425. this.$emit("init");
  426. } else {
  427. this.$message.error("新增失败:" + res.data.msg);
  428. // setTimeout(() => {
  429. // this.closePop();
  430. // }, 2000);
  431. // return true;
  432. }
  433. });
  434. } else {
  435. return false;
  436. }
  437. });
  438. } else {
  439. return false;
  440. }
  441. });
  442. }
  443. else if (this.show_type == 2) {
  444. this.$refs[supplier].validate((valid) => {
  445. if (valid) {
  446. this.$refs[formName].validate((valid) => {
  447. if (valid) {
  448. this.recordInfo.contacts.forEach((el) => {
  449. if (!el.phone) {
  450. el.phone = "";
  451. }
  452. if (!el.address) {
  453. el.address = "";
  454. }
  455. if (!el.id) {
  456. el.id = 0;
  457. }
  458. });
  459. let params = {
  460. suppliercode: this.supplier.supplierCode || "",
  461. suppliername: this.supplier.supplierName || "",
  462. id: this.supplier_ids || 0,
  463. suppliertype: this.supplier.supplierType || "",
  464. vatrate: this.supplier.vatRate || 0,
  465. number: this.supplier.number || "",
  466. bank: this.supplier.bank || "",
  467. bankaccount: this.supplier.bankAccount || "",
  468. contacts: [...this.recordInfo.contacts],
  469. };
  470. updatesupply(params).then((res) => {
  471. if (res.data.state == 1) {
  472. this.$message.success("修改成功");
  473. this.closePop();
  474. this.$emit("init");
  475. } else {
  476. this.$message.error("修改失败:" + res.data.msg);
  477. setTimeout(() => {
  478. this.closePop();
  479. }, 2000);
  480. }
  481. });
  482. } else {
  483. return false;
  484. }
  485. });
  486. } else {
  487. return false;
  488. }
  489. });
  490. }
  491. this.contactsinfo();
  492. },
  493. // 获取供应商与联系人 首次打开新增页面判断是否有首要联系人
  494. getcontacts(val) {
  495. let data = {
  496. value: 1,
  497. label: "是",
  498. };
  499. getsupplyandcontactone({ id: val }).then((res) => {
  500. if (res.data.code == 0) {
  501. this.recordInfo.contacts = res.data.data.contact;
  502. if (this.recordInfo.contacts.length == 0) {
  503. this.recordInfo.contacts = [{}];
  504. this.recordInfo.contacts[0].is_first = data.value;
  505. }
  506. // else if (this.recordInfo.contacts.length == 1) {
  507. // let val = res.data.data.contact[0];
  508. // this.recordInfo.contacts[0].is_first = data.value;
  509. // this.recordInfo.contacts[0] = {
  510. // id: parseFloat(val.id),
  511. // name: val.name,
  512. // address: val.address,
  513. // phone: val.phone,
  514. // };
  515. // }
  516. }
  517. });
  518. },
  519. // 首要联系人选择变更动态展示
  520. changeName(data, scope) {
  521. let data1 = {
  522. value: 0,
  523. label: "否",
  524. };
  525. let data2 = {
  526. value: 1,
  527. label: "是",
  528. };
  529. let arr = [];
  530. if (this.recordInfo.contacts.length <= 1) {
  531. this.recordInfo.contacts[0].is_first = data2.value;
  532. } else {
  533. this.recordInfo.contacts.forEach((el, index) => {
  534. if (scope.$index == index) {
  535. el.is_first = data;
  536. } else {
  537. el.is_first = data1.value;
  538. }
  539. arr.push(el.is_first);
  540. });
  541. if (arr.includes(1)) {
  542. return;
  543. } else {
  544. this.recordInfo.contacts[0].is_first = data2.value;
  545. }
  546. }
  547. },
  548. // 添加表单行
  549. handleAdd() {
  550. let data = {};
  551. this.recordInfo.contacts.push(data);
  552. },
  553. // 删除表单行
  554. handleDelete(index, data) {
  555. let params = {
  556. id: data.id,
  557. };
  558. if (params.id == undefined || params.id == "undefined") {
  559. this.recordInfo.contacts.splice(index, 1);
  560. } else {
  561. if (this.show_type == 1) {
  562. if (this.recordInfo.contacts.length <= 1) {
  563. return;
  564. } else {
  565. this.recordInfo.contacts.splice(index, 1);
  566. }
  567. } else if (this.show_type == 2) {
  568. delcontactone(params).then((res) => {
  569. if (res.data.state == 1) {
  570. this.$message.success("删除成功!!:", index);
  571. this.getcontacts(this.supplier_ids);
  572. } else {
  573. this.$message.error(res.data.data.list);
  574. }
  575. });
  576. }
  577. }
  578. },
  579. //表格判断是否填入信息
  580. contactsinfo() {
  581. let info = this.tableData;
  582. return new Promise((resolve, reject) => {
  583. // if (info) {
  584. // resolve(info);
  585. // } else {
  586. // reject("error");
  587. info.forEach((i) => {
  588. if (
  589. i.contacts != "" &&
  590. i.phone != "" &&
  591. i.id != "" &&
  592. i.address != "" &&
  593. i.FirstConcats != ""
  594. ) {
  595. resolve(info);
  596. } else {
  597. reject("error");
  598. }
  599. });
  600. // }
  601. })
  602. .then((res) => {
  603. // console.log(res, "ooo");
  604. })
  605. .catch((err) => {
  606. // console.log(err, "ddd");
  607. });
  608. },
  609. },
  610. };
  611. </script>
  612. <style lang="scss" scoped>
  613. .demo-form-inline {
  614. .el-col-6 {
  615. width: 50%;
  616. }
  617. .el-input {
  618. width: 75%;
  619. }
  620. }
  621. .el-dialog__body {
  622. .el-form-item__content {
  623. .el-autocomplete {
  624. width: 75% !important;
  625. }
  626. .el-select.el-select--medium {
  627. width: 85% !important;
  628. }
  629. }
  630. }
  631. .tablebtn {
  632. padding: 10px 12px;
  633. }
  634. /deep/.el-form.tableclass {
  635. .el-table__header-wrapper {
  636. .el-table__header {
  637. width: 625px !important;
  638. }
  639. }
  640. .el-table__body-wrapper.is-scrolling-none {
  641. .el-table__body {
  642. width: 625px !important;
  643. }
  644. }
  645. }
  646. /deep/ .el-form-item__error {
  647. // display: none !important;
  648. }
  649. // /deep/ .el-table__body-wrapper::-webkit-scrollbar {
  650. // width: 10px;
  651. // height: 10px;
  652. // }
  653. /deep/ .el-table--scrollable-x .el-table__body-wrapper {
  654. overflow: auto;
  655. }
  656. /deep/ .gutter {
  657. width: 22px !important;
  658. display: inline-block !important;
  659. }
  660. /deep/ .el-table__fixed-right-patch {
  661. width: 22px !important;
  662. }
  663. /deep/ .el-table__fixed-right {
  664. bottom: 0 !important;
  665. left: auto;
  666. right: 22px;
  667. }
  668. </style>