123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <!--
- * @Author: PoJun
- * @Date: 2023-12-22 15:47:43
- * @LastEditors: PoJun
- * @LastEditTime: 2023-12-22 16:42:49
- * @Message: Nothing
- -->
- <template>
- <CommonDrawer
- title="合作记录"
- v-model="visible"
- :width="720"
- @onClose="onClose"
- :btnLoading="btnLoading"
- :showConfirm="false"
- >
- <CommonTable
- :showCheckbox="true"
- :showSeq="false"
- ref="recordsTable"
- :titles="titles"
- :optButton="optButton"
- @optClick="optClick"
- url="/srmCooperates/page"
- :extra="{ supplierId: detailId }"
- >
- <template slot="extraBtns">
- <a-button type="primary" @click="optClick(null, 'new')">新增</a-button>
- <a-button type="danger" ghost @click="deleteBatch">删除</a-button>
- </template>
- <template #delete="{ row }">
- <a-popconfirm placement="topRight" @confirm="deleteItem(row)">
- <span slot="title">确定删除当前记录吗?</span>
- <a-button type="link">删除</a-button>
- </a-popconfirm>
- </template>
- </CommonTable>
- <a-modal v-model="showModal" :zIndex="1002" title="编辑记录" ok-text="确认" cancel-text="取消" @ok="hideModal">
- <a-form-model ref="authForm" :model="form" :rules="rules">
- <a-form-model-item label="合作内容" prop="content">
- <a-input v-model="form.content" placeholder="请输入..." />
- </a-form-model-item>
- <a-form-model-item label="时间" prop="time">
- <a-date-picker valueFormat="YYYY-MM-DD" v-model="form.time" style="width: 100%" />
- </a-form-model-item>
- </a-form-model>
- </a-modal>
- </CommonDrawer>
- </template>
- <script>
- import CommonDrawer from "@/components/table/CommonDrawer.vue";
- import CommonTable from "@/components/table/CommonTable.vue";
- import { addCooperates, updateCooperates, deleteCooperates, batchDeleteCooperates } from "@/api/index.js";
- export default {
- name: "SupplierDetail",
- components: { CommonDrawer, CommonTable },
- props: {
- detailId: {
- type: String,
- default: "",
- },
- detailTitle: {
- type: String,
- default: "详情",
- },
- },
- data() {
- return {
- btnLoading: false,
- visible: true,
- showModal: false,
- form: {
- time: null,
- content: "",
- supplierId: this.detailId,
- },
- rules: {
- time: [{ required: true, message: "必填项不能为空", trigger: ["change", "blur"] }],
- content: [{ required: true, message: "必填项不能为空", trigger: ["change", "blur"] }],
- },
- optButton: [
- {
- id: "edit",
- name: "编辑",
- },
- {
- id: "delete",
- name: "删除",
- },
- ],
- titles: [
- {
- field: "content",
- title: "内容",
- width: 350,
- fixed: true,
- },
- {
- field: "time",
- title: "时间",
- width: 120,
- },
- ],
- detaiType: "",
- };
- },
- methods: {
- // 列操作
- optClick(row, type) {
- this.detaiType = type;
- this.showModal = true;
- this.form.content = row?.content;
- this.form.time = row?.time;
- },
- onClose() {
- setTimeout(() => {
- this.$emit("close");
- }, 200);
- },
- deleteItem({ id }) {
- deleteCooperates(id).then(() => {
- this.$refs.recordsTable.refresh();
- });
- },
- // 批量删除
- deleteBatch() {
- const list = this.$refs.recordsTable.getCheckboxRecords();
- if (list.length > 0) {
- const ids = list.map(item => item.id);
- this.$confirm({
- title: "数据删除无法复原,确认删除?",
- onOk: () => {
- batchDeleteCooperates(ids).then(() => {
- this.$refs.recordsTable.refresh();
- });
- },
- });
- } else {
- this.$message.warning("请先选择数据!");
- }
- },
- hideModal() {
- this.$refs.authForm.validate(isValid => {
- if (isValid) {
- const doAjax =
- this.detaiType == "new" ? addCooperates(this.form) : updateCooperates(this.form, this.detailId);
- doAjax.then(() => {
- this.$refs.recordsTable.refresh();
- this.showModal = false;
- });
- }
- });
- },
- },
- created() {},
- };
- </script>
- <style lang="less" scoped></style>
|