123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <script>
- import test from "@/components/form-test/index.vue";
- import query from "@/components/query/index.vue";
- import byTable from "@/components/by-table/index.js";
- import sendSubscribe from "./sendSubscribe.vue";
- import subscribeDetails from "@/components/purchase/subscribeDetails.vue";
- import * as API from "@/api/purchase-management/subscribe/index.js";
- import { warehouseSelectList } from "@/api/product-material/warehouse/index.js";
- export default {
- components: {
- test,
- byTable,
- query,
- sendSubscribe,
- subscribeDetails,
- },
- data() {
- return {
- subscribeStatusList: [],
- productTypeList: [],
- materialTypeList: [],
- warehouseSelectList: [],
- warehouseTypeList: [],
- btnForm: {
- otherButton: {
- list: [
- {
- name: "发起申购",
- methodsText: "add",
- type: "primary",
- add: () => {
- this.handleAdd();
- },
- },
- ],
- },
- },
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- keyword: "",
- warehouseId: "",
- status: null,
- code: "",
- goodsCode: "",
- goodsName: "",
- applyUserId: "",
- startTime: "",
- endTime: "",
- },
- selectConfig: [
- {
- label: "申购状态",
- prop: "status",
- data: [],
- },
- ],
- tableList: [],
- total: 0,
- loading: false,
- titleText: "",
- open: false,
- form: {
- id: "",
- receiptWarehouseId: "",
- planArrivalTime: "",
- cause: "",
- goodsId: [],
- },
- detailsDialog: false,
- rowData: {},
- };
- },
- created() {
- const businessDictData = JSON.parse(
- window.localStorage.getItem("businessDict")
- );
- this.productTypeList = businessDictData.find(
- (item) => item.code === "productType"
- ).children;
- this.subscribeStatusList = businessDictData.find(
- (item) => item.code === "purchaseStatus"
- ).children;
- this.warehouseTypeList = businessDictData.find(
- (item) => item.code === "warehouseType"
- ).children;
- this.materialTypeList = businessDictData.find(
- (item) => item.code === "materialType"
- ).children;
- this.selectConfig[0].data = this.subscribeStatusList.map((item) => ({
- label: item.dictValue,
- value: item.dictKey,
- }));
- warehouseSelectList().then((res) => {
- this.warehouseSelectList = res.data.data;
- });
- this.getList();
- },
- methods: {
- getList() {
- this.loading = true;
- API.subscribeList(this.queryParams).then(
- (res) => {
- this.tableList = res.data.data.records;
- this.total = res.data.data.total;
- this.loading = false;
- },
- (err) => {
- console.log("subscribeList: " + err);
- this.loading = false;
- }
- );
- },
- handleQuery() {
- this.getList();
- },
- handleAdd() {
- this.form = {
- id: "",
- receiptWarehouseId: "",
- planArrivalTime: "",
- cause: "",
- goodsId: [],
- };
- this.titleText = "add";
- this.open = true;
- },
- handleCancel() {
- this.open = false;
- },
- handleEdit(row) {
- this.titleText = "edit";
- this.open = true;
- this.$nextTick(() => {
- this.$refs.sendSubscribe.loading = true;
- API.subscribeDetails({ id: row.id }).then(
- (res) => {
- const data = res.data.data;
- const goodsItem = {
- goodsId: data.goodsId,
- quantity: data.quantity,
- code: data.goodsCode,
- name: data.goodsName,
- type: data.goodsType,
- unit: data.goodsUnit,
- stock: data.stockQuantity,
- };
- this.form = {
- id: data.id,
- receiptWarehouseId: data.receiptWarehouseId,
- planArrivalTime: data.planArrivalTime,
- cause: data.cause,
- goodsId: [goodsItem],
- };
- this.$refs.sendSubscribe.loading = false;
- },
- (err) => {
- console.log("subscribeDetails: ", err);
- this.$refs.sendSubscribe.loading = false;
- }
- );
- });
- },
- handleSubmit() {
- if (!this.form.id) {
- const productList = this.form.goodsId.map((x) => {
- return {
- ...x,
- planArrivalTime: this.form.planArrivalTime,
- receiptWarehouseId: this.form.receiptWarehouseId,
- cause: this.form.cause,
- };
- });
- API.subscribeAdd(productList).then(
- () => {
- this.msgSuccess("添加成功");
- this.$refs.sendSubscribe.loading = false;
- this.open = false;
- this.getList();
- },
- (err) => {
- console.log("subscribeAdd: " + err);
- this.$refs.sendSubscribe.loading = false;
- }
- );
- } else {
- this.form.quantity = this.form.goodsId[0].quantity;
- this.form.goodsId = this.form.goodsId[0].goodsId;
- API.subscribeEdit(this.form).then(
- () => {
- this.msgSuccess("编辑成功");
- this.open = false;
- this.$refs.sendSubscribe.loading = false;
- this.getList();
- },
- (err) => {
- console.log("subscribeEdit: " + err);
- this.$refs.sendSubscribe.loading = false;
- }
- );
- }
- },
- handleDelete(row) {
- this.$confirm("是否确认此操作 ?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- API.subscribeDel({ id: row.id }).then(() => {
- this.msgSuccess("删除成功");
- this.getList();
- });
- });
- },
- showAddress(row) {
- return (
- <div>
- {row.countryName} , {row.provinceName} , {row.cityName}
- </div>
- );
- },
- handleLookDetails(row) {
- this.rowData = { ...row };
- this.detailsDialog = true;
- },
- },
- };
- </script>
- <template>
- <div class="box-card">
- <el-card class="header">
- <test :form-config="btnForm"></test>
- </el-card>
- <el-card class="body-main">
- <query
- :selectConfig="selectConfig"
- :req="queryParams"
- :isShowMore="true"
- @handleQuery="handleQuery"
- @handleMore="
- () => {
- queryDialog = true;
- }
- "
- ></query>
- <el-table :data="tableList" v-loading="loading">
- <el-table-column label="申购单号" align="left" prop="code" width="140">
- <template slot-scope="scope">
- <div class="show_underline" @click="handleLookDetails(scope.row)">
- {{ scope.row.code }}
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="物品编码"
- align="left"
- prop="goodsCode"
- width="120"
- />
- <el-table-column label="物品名称" align="left" prop="goodsName" />
- <el-table-column
- label="物品类型"
- align="left"
- width="100"
- :formatter="(row) => dictDataEcho(row.goodsType, productTypeList)"
- />
- <el-table-column
- label="单位"
- align="left"
- prop="goodsUnit"
- width="100"
- />
- <el-table-column
- label="申购数量"
- align="left"
- prop="quantity"
- width="120"
- />
- <el-table-column
- label="申购人"
- align="left"
- prop="createName"
- width="120"
- />
- <el-table-column
- label="申购时间"
- align="left"
- prop="createTime"
- width="160"
- :formatter="
- (row) => {
- return row.createTime.slice(0, 10);
- }
- "
- />
- <el-table-column
- label="要求到货时间"
- align="left"
- prop="planArrivalTime"
- width="160"
- :formatter="
- (row) => {
- return row.planArrivalTime.slice(0, 10);
- }
- "
- />
- <!-- <el-table-column
- :label="$t('purchase_management.subscribe.harvestWarehouse')"
- align="left"
- prop="warehouseName"
- /> -->
- <!--
- <el-table-column
- :label="$t('purchase_management.subscribe.subscribeReason')"
- align="left"
- prop="cause"
- /> -->
- <el-table-column
- label="采购状态"
- align="left"
- width="120"
- :formatter="(row) => dictDataEcho(row.status, subscribeStatusList)"
- />
- <!-- <el-table-column label="操作" align="center" width="120">
- <template slot-scope="scope">
- <el-button
- type="text"
- v-if="scope.row.status === 10"
- @click="handleEdit(scope.row)"
- >编辑
- </el-button>
- <el-button
- type="text"
- v-if="scope.row.status === 10"
- @click="handleDelete(scope.row)"
- >删除
- </el-button>
- </template>
- </el-table-column> -->
- </el-table>
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </el-card>
- <el-dialog
- :title="
- titleText === 'add'
- ? $t('purchase_management.subscribe.sendSubscribe')
- : $t('purchase_management.subscribe.subscribeEdit')
- "
- :visible.sync="open"
- v-if="open"
- width="80%"
- top="60px"
- >
- <send-subscribe
- :form="form"
- :productTypeList="productTypeList"
- :materialTypeList="materialTypeList"
- :warehouseSelectList="warehouseSelectList"
- :warehouseTypeList="warehouseTypeList"
- @submit="handleSubmit"
- @cancel="handleCancel"
- ref="sendSubscribe"
- ></send-subscribe>
- </el-dialog>
- <el-dialog
- title="申购详情"
- v-if="detailsDialog"
- :visible.sync="detailsDialog"
- width="50%"
- top="60px"
- >
- <subscribeDetails :rowData="rowData"></subscribeDetails>
- </el-dialog>
- </div>
- </template>
- <style lang="scss" scoped>
- .box-card {
- height: calc(100vh - 110px);
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- .header {
- // height: 100px;
- margin-bottom: 10px;
- box-sizing: border-box;
- }
- .body-main {
- flex: 1;
- overflow-y: auto;
- }
- }
- </style>
|