123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776 |
- <template>
- <div class="tenant">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- highlight-current-row
- :selectConfig="selectConfig"
- :row-class-name="getRowClass"
- :table-events="{
- select: selectRow,
- }"
- :action-list="[
- {
- text: '转生产',
- disabled: selectData.length === 0,
- action: () => transferToProduction(),
- },
- {
- text: '采购',
- disabled: selectData.length === 0,
- action: () => start(),
- },
- ]"
- @get-list="getList"
- >
- <template #claimTime="{ item }">
- <div>
- <span v-if="item.claimTime">{{ item.claimTime }}</span>
- <span v-else>未到账</span>
- </div>
- </template>
- <template #details="{ item }">
- <div>
- <el-button
- type="primary"
- link
- v-if="item.expendQuantity >= 0"
- @click="handleClickDetails(item)"
- >查看</el-button
- >
- <el-button
- type="primary"
- link
- style="color: #f54a45"
- v-else
- @click="handleClickDetails(item)"
- >查看</el-button
- >
- </div>
- </template>
- <template #btn="{ item }">
- <div v-if="item.expendQuantity > 0">
- <el-button type="primary" link @click="start(10, item)"
- >采购</el-button
- >
- <el-button type="primary" link @click="transferToProduction(item)"
- >转生产</el-button
- >
- </div>
- <div v-else-if="item.expendQuantity == 0">
- <el-button type="primary" link @click="handleFollow(item)"
- >跟进</el-button
- >
- <el-button type="primary" link @click="lookRecords(item)"
- >跟进记录</el-button
- >
- </div>
- <div v-else>
- <el-button
- type="primary"
- link
- style="color: #f54a45"
- @click="handleFollow(item)"
- >跟进</el-button
- >
- <el-button
- type="primary"
- link
- style="color: #f54a45"
- @click="lookRecords(item)"
- >跟进记录</el-button
- >
- </div>
- </template>
- </byTable>
- <el-dialog
- title="转生产"
- v-if="dialogVisible"
- v-model="dialogVisible"
- width="1200"
- v-loading="loadingDialog"
- >
- <byForm
- :formConfig="formConfig"
- :formOption="formOption"
- v-model="formData.data"
- :rules="rules"
- ref="submit"
- >
- <template #details>
- <div style="width: 100%">
- <el-table
- :data="formData.data.list"
- style="width: 100%; margin-top: 16px"
- >
- <el-table-column
- prop="productCode"
- label="物品编码"
- width="140"
- />
- <el-table-column
- prop="productName"
- label="物品名称"
- min-width="220"
- />
- <el-table-column
- prop="productUnit"
- label="单位"
- width="100"
- :formatter="
- (row) => dictValueLabel(row.productUnit, productUnit)
- "
- />
- <el-table-column
- prop="expendQuantity"
- label="待处理数量"
- width="120"
- />
- <el-table-column label="转生产数量" width="160">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item
- :prop="'list.' + $index + '.quantity'"
- :rules="rules.quantity"
- :inline-message="true"
- >
- <el-input-number
- v-model="row.quantity"
- placeholder="请输入数量"
- style="width: 100%"
- :precision="0"
- :controls="false"
- :min="0"
- />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="完工期限" width="180">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item
- :prop="'list.' + $index + '.time'"
- :rules="rules.time"
- :inline-message="true"
- >
- <el-date-picker
- v-model="row.time"
- type="date"
- placeholder="请选择"
- value-format="YYYY-MM-DD"
- />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="操作"
- width="80"
- fixed="right"
- >
- <template #default="{ row, $index }">
- <el-button type="primary" link @click="handleDelete($index)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="dialogVisible = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitForm()" size="large"
- >确 定</el-button
- >
- </template>
- </el-dialog>
- <el-dialog
- title="填写跟进"
- v-if="dialogVisibleOne"
- v-model="dialogVisibleOne"
- width="500"
- v-loading="loadingDialog"
- >
- <byForm
- :formConfig="formConfigOne"
- :formOption="formOption"
- v-model="formData.dataOne"
- :rules="rulesOne"
- ref="submitOne"
- >
- </byForm>
- <template #footer>
- <el-button @click="dialogVisibleOne = false" size="large"
- >取 消</el-button
- >
- <el-button type="primary" @click="submitFormOne()" size="large"
- >确 定</el-button
- >
- </template>
- </el-dialog>
- <el-dialog title="跟进记录" v-model="dialogVisibleTwo" width="500">
- <div style="width: 100%">
- <el-timeline :reverse="false">
- <el-timeline-item
- placement="top"
- v-for="(activity, index) in activities"
- :key="index"
- :timestamp="activity.followUpTime"
- >
- <div>
- 跟进结果:
- <span>{{ activity.resultType ? "已处理" : "处理中" }}</span>
- </div>
- <div style="margin-top: 5px">跟进记录: {{ activity.remark }}</div>
- </el-timeline-item>
- </el-timeline>
- </div>
- </el-dialog>
- <el-dialog
- title="交接单"
- v-if="openHandover"
- v-model="openHandover"
- width="800"
- >
- <byForm
- :formConfig="formHandoverConfig"
- :formOption="formOption"
- v-model="productRow.data"
- >
- <template #remark>
- <div style="width: 100%">
- <Editor
- ref="remarkEditor"
- :readOnly="true"
- :value="productRow.data.remark"
- />
- </div>
- </template>
- <template #file>
- <div style="width: 100%">
- <el-upload
- v-model:fileList="productRow.data.fileList"
- action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
- multiple
- :on-preview="onPreviewFile"
- >
- </el-upload>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="openHandover = false" size="large">关 闭</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import { computed, nextTick, ref } from "vue";
- import { ElMessage } from "element-plus";
- import Editor from "@/components/Editor/index.vue";
- const { proxy } = getCurrentInstance();
- const loading = ref(false);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 3,
- pageNum: 1,
- pageSize: 10,
- status: "15",
- },
- });
- const isReceivedArr = ref([
- { label: "是", value: "1" },
- { label: "否", value: "0" },
- ]);
- const corporationArr = ref([]);
- const selectConfig = computed(() => [
- {
- label: "归属公司",
- prop: "corporationId",
- data: corporationArr.value,
- },
- {
- label: "是否到账",
- prop: "isReceived",
- data: isReceivedArr.value,
- },
- ]);
- const config = computed(() => {
- return [
- {
- type: "selection",
- attrs: {
- checkAtt: "isCheck",
- },
- },
- {
- attrs: {
- label: "归属公司",
- prop: "corporationName",
- },
- },
- {
- attrs: {
- label: "外销合同编号",
- prop: "contractCode",
- width: "160",
- },
- },
- {
- attrs: {
- label: "下单时间",
- prop: "contractTime",
- width: "155",
- },
- },
- {
- attrs: {
- label: "合同到账时间",
- slot: "claimTime",
- width: "155",
- },
- },
- {
- attrs: {
- label: "业务员",
- prop: "userName",
- },
- },
- {
- attrs: {
- label: "版本号",
- prop: "contractVersion",
- },
- render(contractVersion) {
- return "v" + contractVersion;
- },
- },
- {
- attrs: {
- label: "产品编码",
- prop: "productCode",
- },
- },
- {
- attrs: {
- label: "产品名称",
- prop: "productName",
- },
- },
- {
- attrs: {
- label: "单位",
- prop: "productUnit",
- width: "80",
- },
- render(unit) {
- return proxy.dictValueLabel(unit, productUnit.value);
- },
- },
- {
- attrs: {
- label: "已发起数量",
- prop: "startPurchaseCount",
- width: "110",
- },
- },
- {
- attrs: {
- label: "待处理数量",
- prop: "expendQuantity",
- width: "110",
- },
- },
- {
- attrs: {
- label: "详情",
- width: "100",
- align: "center",
- slot: "details",
- },
- },
- {
- attrs: {
- label: "操作",
- slot: "btn",
- width: "140",
- align: "center",
- fixed: "right",
- },
- },
- ];
- });
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy
- .post("/contractProduct/page", sourceList.value.pagination)
- .then((message) => {
- sourceList.value.data = message.rows.map((x) => ({
- ...x,
- isCheck: true,
- }));
- sourceList.value.pagination.total = message.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getList();
- const productUnit = ref([]);
- const getDict = () => {
- proxy
- .post("/corporation/page", { pageNum: 1, pageSize: 9999 })
- .then((res) => {
- corporationArr.value = res.rows.map((x) => ({
- ...x,
- label: x.name,
- value: x.id,
- }));
- });
- proxy.getDictOne(["unit"]).then((res) => {
- productUnit.value = res["unit"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- });
- };
- getDict();
- const selectData = ref([]);
- const selectRow = (data) => {
- selectData.value = data;
- };
- const start = (type, row) => {
- if (type === 10) {
- selectData.value = [row];
- }
- if (selectData.value.length > 0) {
- let ids = selectData.value.map((x) => x.id).join();
- let arr = selectData.value.map((x) => ({
- contractId: x.contractId,
- contractCode: x.contractCode,
- claimTime: x.contractTime,
- }));
- let newArr = [];
- for (let i = 0; i < arr.length; i++) {
- const e = arr[i];
- let flag = newArr.some((x) => x.contractId === e.contractId);
- if (!flag) {
- newArr.push(e);
- }
- }
- proxy.$router.replace({
- path: "/platform_manage/process/processApproval",
- query: {
- flowKey: "purchase_flow",
- type: "handoverSlip",
- random: proxy.random(),
- ids,
- arr: JSON.stringify(newArr),
- },
- });
- } else {
- return ElMessage({
- message: "请勾选数据!",
- type: "info",
- });
- }
- };
- const dialogVisible = ref(false);
- const dialogVisibleOne = ref(false);
- const dialogVisibleTwo = ref(false);
- const loadingDialog = ref(false);
- const submit = ref(null);
- const submitOne = ref(null);
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const formData = reactive({
- data: {
- list: [],
- },
- dataOne: {},
- });
- const formConfig = computed(() => {
- return [
- {
- type: "slot",
- slotName: "details",
- label: "产品明细",
- },
- ];
- });
- const rules = ref({
- quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
- time: [{ required: true, message: "请选择完工期限", trigger: "change" }],
- });
- const formConfigOne = computed(() => {
- return [
- {
- type: "select",
- prop: "resultType",
- label: "跟进结果",
- data: [
- {
- label: "处理中",
- value: "0",
- },
- {
- label: "已处理",
- value: "1",
- },
- ],
- },
- {
- type: "date",
- itemType: "datetime",
- prop: "followUpTime",
- label: "跟进时间",
- format: "YYYY-MM-DD HH:mm:ss",
- },
- {
- type: "input",
- prop: "remark",
- label: "跟进记录",
- itemType: "textarea",
- },
- ];
- });
- const rulesOne = ref({
- resultType: [
- { required: true, message: "请选择跟进结果", trigger: "change" },
- ],
- followUpTime: [
- { required: true, message: "请选择跟进时间", trigger: "change" },
- ],
- remark: [{ required: true, message: "请输入跟进记录", trigger: "blur" }],
- });
- const activities = ref([]);
- const lookRecords = (row) => {
- proxy
- .post("/contractProductFollowUp/list", {
- contractProductId: row.productId,
- })
- .then((res) => {
- if (res && res.length > 0) {
- activities.value = res;
- dialogVisibleTwo.value = true;
- } else {
- return ElMessage({
- message: "暂无跟进记录!",
- type: "info",
- });
- }
- });
- };
- const handleFollow = (row) => {
- formData.dataOne = {
- contractProductId: row.productId,
- };
- dialogVisibleOne.value = true;
- };
- const submitFormOne = () => {
- submitOne.value.handleSubmit(() => {
- loadingDialog.value = true;
- proxy.post("/contractProductFollowUp/add", formData.dataOne).then(
- () => {
- ElMessage({
- message: "提交成功",
- type: "success",
- });
- dialogVisibleOne.value = false;
- getList();
- },
- (err) => {
- console.log(err);
- loadingDialog.value = false;
- }
- );
- });
- };
- const transferToProduction = (row) => {
- if (row && row.id) {
- formData.data = {
- list: [
- {
- sourceId: row.id,
- source: "1",
- productId: row.productId,
- productCode: row.productCode,
- productName: row.productName,
- productUnit: row.productUnit,
- expendQuantity: row.expendQuantity,
- quantity: undefined,
- },
- ],
- };
- } else {
- formData.data = {
- list: selectData.value.map((item) => {
- return {
- sourceId: item.id,
- source: "1",
- productId: item.productId,
- productCode: item.productCode,
- productName: item.productName,
- productUnit: item.productUnit,
- expendQuantity: item.expendQuantity,
- quantity: undefined,
- };
- }),
- };
- }
- dialogVisible.value = true;
- };
- watch(selectData, (newVal) => {
- if (newVal.length == 0) {
- sourceList.value.data.forEach((x) => {
- x.isCheck = true;
- });
- } else if (newVal.length == 1) {
- const current = newVal[0];
- sourceList.value.data.forEach((x) => {
- if (x.contractId !== current.contractId) {
- x.isCheck = false;
- }
- });
- }
- });
- const submitForm = () => {
- submit.value.handleSubmit(() => {
- if (!(formData.data.list && formData.data.list.length > 0)) {
- return ElMessage("请至少添加一条产品明细");
- }
- loadingDialog.value = true;
- proxy.post("/workOrder/addBatch", formData.data.list).then(
- () => {
- ElMessage({
- message: "提交成功",
- type: "success",
- });
- dialogVisible.value = false;
- getList();
- },
- (err) => {
- console.log(err);
- loadingDialog.value = false;
- }
- );
- });
- };
- const handleDelete = (index) => {
- formData.data.list.splice(index, 1);
- };
- const getRowClass = ({ row }) => {
- if (row.expendQuantity < 0) {
- return "redClass";
- }
- return "";
- };
- const openHandover = ref(false);
- const productRow = reactive({
- data: {
- productName: "",
- productModel: "",
- remark: "",
- fileList: [],
- },
- });
- const formHandoverConfig = computed(() => {
- return [
- {
- type: "title",
- title: "产品信息",
- label: "",
- },
- {
- type: "input",
- prop: "productName",
- label: "产品名称",
- itemType: "text",
- disabled: true,
- },
- {
- type: "input",
- prop: "productModel",
- label: "规格型号",
- itemType: "text",
- disabled: true,
- },
- {
- type: "slot",
- slotName: "remark",
- label: "交接单",
- },
- {
- type: "slot",
- prop: "file",
- slotName: "file",
- label: "附件",
- },
- ];
- });
- const remarkEditor = ref(null);
- const handleClickDetails = (row) => {
- proxy
- .post("/flowProcess/getStartData", { flowId: row.flowId })
- .then(async (res) => {
- const current = res.contractProductList.find(
- (x) => x.productId === row.productId
- );
- productRow.data = current || {};
- productRow.data.fileList =
- current.fileList.map((x) => ({
- raw: x,
- name: x.fileName,
- url: x.fileUrl,
- })) || [];
- openHandover.value = true;
- await nextTick();
- remarkEditor.value.changeHtml(productRow.data.remark);
- });
- };
- const onPreviewFile = (file) => {
- window.open(file.raw.fileUrl, "_blank");
- };
- </script>
- <style lang="scss" scoped>
- .tenant {
- margin: 20px;
- }
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- :deep(.el-table__header-wrapper .el-checkbox) {
- display: none;
- }
- </style>
- <style>
- .redClass {
- color: #f54a45 !important;
- }
- </style>
|