WorkingRecords.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <!--
  2. * @Author: PoJun
  3. * @Date: 2023-12-22 15:47:43
  4. * @LastEditors: PoJun
  5. * @LastEditTime: 2023-12-22 16:42:49
  6. * @Message: Nothing
  7. -->
  8. <template>
  9. <CommonDrawer
  10. title="合作记录"
  11. v-model="visible"
  12. :width="720"
  13. @onClose="onClose"
  14. :btnLoading="btnLoading"
  15. :showConfirm="false"
  16. >
  17. <CommonTable
  18. :showCheckbox="true"
  19. :showSeq="false"
  20. ref="recordsTable"
  21. :titles="titles"
  22. :optButton="optButton"
  23. @optClick="optClick"
  24. url="/srmCooperates/page"
  25. :extra="{ supplierId: detailId }"
  26. >
  27. <template slot="extraBtns">
  28. <a-button type="primary" @click="optClick(null, 'new')">新增</a-button>
  29. <a-button type="danger" ghost @click="deleteBatch">删除</a-button>
  30. </template>
  31. <template #delete="{ row }">
  32. <a-popconfirm placement="topRight" @confirm="deleteItem(row)">
  33. <span slot="title">确定删除当前记录吗?</span>
  34. <a-button type="link">删除</a-button>
  35. </a-popconfirm>
  36. </template>
  37. </CommonTable>
  38. <a-modal v-model="showModal" :zIndex="1002" title="编辑记录" ok-text="确认" cancel-text="取消" @ok="hideModal">
  39. <a-form-model ref="authForm" :model="form" :rules="rules">
  40. <a-form-model-item label="合作内容" prop="content">
  41. <a-input v-model="form.content" placeholder="请输入..." />
  42. </a-form-model-item>
  43. <a-form-model-item label="时间" prop="time">
  44. <a-date-picker valueFormat="YYYY-MM-DD" v-model="form.time" style="width: 100%" />
  45. </a-form-model-item>
  46. </a-form-model>
  47. </a-modal>
  48. </CommonDrawer>
  49. </template>
  50. <script>
  51. import CommonDrawer from "@/components/table/CommonDrawer.vue";
  52. import CommonTable from "@/components/table/CommonTable.vue";
  53. import { addCooperates, updateCooperates, deleteCooperates, batchDeleteCooperates } from "@/api/index.js";
  54. export default {
  55. name: "SupplierDetail",
  56. components: { CommonDrawer, CommonTable },
  57. props: {
  58. detailId: {
  59. type: String,
  60. default: "",
  61. },
  62. detailTitle: {
  63. type: String,
  64. default: "详情",
  65. },
  66. },
  67. data() {
  68. return {
  69. btnLoading: false,
  70. visible: true,
  71. showModal: false,
  72. form: {
  73. time: null,
  74. content: "",
  75. supplierId: this.detailId,
  76. },
  77. rules: {
  78. time: [{ required: true, message: "必填项不能为空", trigger: ["change", "blur"] }],
  79. content: [{ required: true, message: "必填项不能为空", trigger: ["change", "blur"] }],
  80. },
  81. optButton: [
  82. {
  83. id: "edit",
  84. name: "编辑",
  85. },
  86. {
  87. id: "delete",
  88. name: "删除",
  89. },
  90. ],
  91. titles: [
  92. {
  93. field: "content",
  94. title: "内容",
  95. width: 350,
  96. fixed: true,
  97. },
  98. {
  99. field: "time",
  100. title: "时间",
  101. width: 120,
  102. },
  103. ],
  104. detaiType: "",
  105. };
  106. },
  107. methods: {
  108. // 列操作
  109. optClick(row, type) {
  110. this.detaiType = type;
  111. this.showModal = true;
  112. this.form.content = row?.content;
  113. this.form.time = row?.time;
  114. },
  115. onClose() {
  116. setTimeout(() => {
  117. this.$emit("close");
  118. }, 200);
  119. },
  120. deleteItem({ id }) {
  121. deleteCooperates(id).then(() => {
  122. this.$refs.recordsTable.refresh();
  123. });
  124. },
  125. // 批量删除
  126. deleteBatch() {
  127. const list = this.$refs.recordsTable.getCheckboxRecords();
  128. if (list.length > 0) {
  129. const ids = list.map(item => item.id);
  130. this.$confirm({
  131. title: "数据删除无法复原,确认删除?",
  132. onOk: () => {
  133. batchDeleteCooperates(ids).then(() => {
  134. this.$refs.recordsTable.refresh();
  135. });
  136. },
  137. });
  138. } else {
  139. this.$message.warning("请先选择数据!");
  140. }
  141. },
  142. hideModal() {
  143. this.$refs.authForm.validate(isValid => {
  144. if (isValid) {
  145. const doAjax =
  146. this.detaiType == "new" ? addCooperates(this.form) : updateCooperates(this.form, this.detailId);
  147. doAjax.then(() => {
  148. this.$refs.recordsTable.refresh();
  149. this.showModal = false;
  150. });
  151. }
  152. });
  153. },
  154. },
  155. created() {},
  156. };
  157. </script>
  158. <style lang="less" scoped></style>