123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916 |
- <template>
- <div>
- <Toptitle :title="$route.query.type == 1 ? '新增请购单' : '请购单详情'">
- <slot name="titleButton">
- <Button @click="goBack" type="primary" ghost style="margin-right: 10px"
- >返回</Button
- >
- <Button
- @click="postData"
- type="primary"
- v-show="!isCheck"
- ghost
- style="margin-right: 10px"
- >确定</Button
- >
- </slot>
- </Toptitle>
- <div class="content_topform">
- <Form :label-width="90" :model="searchData">
- <FormItem label="项目名称:">
- <Input
- type="text"
- size="small"
- v-show="!isCheck"
- v-model="searchData.residential_name"
- style="width: 200px; margin-top: 6px"
- placeholder="项目名称"
- >
- <span
- slot="append"
- style="cursor: pointer"
- @click="showProjectModal = true"
- >选择</span
- >
- </Input>
- <span v-show="isCheck">{{ searchData.residential_name }}</span>
- </FormItem>
- <FormItem label="请购类型:">
- <Select
- v-model="searchData.type_id"
- size="small"
- clearable
- v-show="!isCheck"
- filterable
- label-in-value
- style="width: 200px"
- >
- <Option
- v-for="sitem in purchaseTypeList"
- :key="sitem.id"
- :label="sitem.title"
- :value="sitem.id"
- >
- </Option>
- </Select>
- <span
- v-for="item in purchaseTypeList"
- :key="item.id"
- v-show="item.id == searchData.type_id && isCheck"
- >{{ item.title }}</span
- >
- </FormItem>
- <FormItem label="单据号:">
- <Input
- type="text"
- size="small"
- v-show="!isCheck"
- v-model="searchData.purchase_order_apply_no"
- readonly
- style="width: 200px"
- placeholder="自动生成"
- >
- </Input>
- <span v-show="isCheck">{{ searchData.purchase_order_apply_no }}</span>
- </FormItem>
- <FormItem label="制单时间:">
- <DatePicker
- type="date"
- v-show="!isCheck"
- size="small"
- style="width: 200px"
- placeholder="年/月/日"
- v-model="searchData.time"
- ></DatePicker>
- <span v-show="isCheck">{{ func.replaceDate(searchData.time) }}</span>
- </FormItem>
- <FormItem label="备注">
- <Input
- type="textarea"
- v-show="!isCheck"
- size="small"
- v-model="searchData.remark"
- style="width: 200px"
- placeholder="备注"
- >
- </Input>
- <span v-show="isCheck">{{ searchData.remark }}</span>
- </FormItem>
- </Form>
- </div>
- <div class="content_table">
- <div class="content_table_btn">
- <span>请购清单</span>
- <Button
- @click="showModal = true"
- type="primary"
- v-show="!isCheck"
- size="small"
- style="margin-left: 10px"
- >选择物料</Button
- >
- </div>
- <Table :columns="tableColumns" border :data="tableData">
- <template slot="materiel_specs" slot-scope="{ row }">
-
- <div>
- {{ row.long ? row.long : 0 }}*{{ row.width ? row.width : 0 }}*{{
- row.high ? row.high : 0
- }}
- </div>
- </template>
- <template slot="materiel_sort" slot-scope="{ index }">
- <Input
- type="text"
- v-show="!isCheck"
- size="small"
- v-model="tableData[index].type_title"
- placeholder="数量"
- >
- </Input>
- <span v-show="isCheck">{{ tableData[index].type_title }}</span>
- </template>
- <template slot="materiel_name" slot-scope="{ index }">
- <Input
- type="text"
- v-show="!isCheck"
- size="small"
- v-model="tableData[index].title"
- placeholder="数量"
- >
- </Input>
- <span v-show="isCheck">{{ tableData[index].title }}</span>
- </template>
- <template slot="numberSet" slot-scope="{row , index }">
- <Tooltip
- placement="left"
- @on-popper-show="handleToolShow(index, row)"
- >
- <div slot="content">
- <div>
- <div v-for="(_item,_index) in warehouse" :key="_index">
- {{_item.warehouse_title}}:{{_item.num}}
- </div>
- </div>
- </div>
- <Input
- type="text"
- v-show="!isCheck"
- size="small"
- v-model="tableData[index].num"
- placeholder="数量"
- >
- </Input>
- <span v-show="isCheck">{{ tableData[index].num }}</span>
- </Tooltip>
- </template>
- <template slot="arrive_timeSet" slot-scope="{ index }">
- <DatePicker
- type="date"
- size="small"
- transfer
- v-show="!isCheck"
- placeholder="年/月/日"
- v-model="tableData[index].time"
- ></DatePicker>
- <span v-show="isCheck">{{
- func.replaceDate(tableData[index].time)
- }}</span>
- </template>
- <template slot="supply_idSet" slot-scope="{ index }">
- <Select
- v-model="tableData[index].supply_id"
- size="small"
- clearable
- transfer
- v-show="!isCheck"
- filterable
- label-in-value
- >
- <Option
- v-for="sitem in suppliersList"
- :key="sitem.id"
- :label="sitem.title"
- :value="sitem.id"
- >
- </Option>
- </Select>
- <span
- v-for="item in suppliersList"
- :key="item.id"
- v-show="item.id == tableData[index].supply_id && isCheck"
- >{{ item.title }}</span>
- </template>
- <template slot="setSlot" slot-scope="{ row, index }">
- <a
- style="margin: 0 5px"
- :disabled="row.state == 0"
- v-show="!isCheck"
- @click="handleSet(1, row, index)"
- >删除</a>
- </template>
- </Table>
- </div>
- <Modal
- v-model="showModal"
- title="选择物料"
- width="80"
- @on-ok="handleSelect"
- @on-cancel="showModal = false"
- >
- <div class="modal_content">
- <div class="modal_content_left">
- <Tree
- :data="modalData.treeData"
- children-key="list"
- style="width: 100%"
- @on-select-change="handleTreeSlect"
- class="demo-tree-render"
- ></Tree>
- </div>
- <div class="modal_content_center">
- <div class="modal_content_center_top">
- <div>
- <span>物料名称:</span>
- <Input
- type="text"
- v-model="modalData.title"
- placeholder="请输入物料名称"
- />
- </div>
- <Button @click="initModal()" type="primary" style="margin: 0 10px"
- >搜索</Button
- >
- </div>
- <div class="modal_content_center_body">
- <Table
- :columns="modalTableColumns"
- height="520"
- border
- ref="modelTable"
- @on-select-all="handleSelectionAll"
- @on-select-all-cancel="handleSelectionAllCancel"
- @on-select="handleSelection"
- @on-select-cancel="handleSelectionCancel"
- :loading="modalTableLoading"
- :data="modalData.tableData"
- >
- </Table>
- <div class="modal_content_center_footer">
- <Page
- :page-size-opts="[10, 20, 30, 40, 100]"
- @on-page-size-change="changeModalSize"
- @on-change="changeModalPage"
- :current="modal_page_index"
- show-total
- :total="modal_total"
- show-sizer
- :page-size="modal_page_size"
- />
- </div>
- </div>
- </div>
- <div class="modal_content_right">
- <span>已选</span>
- <Table
- :columns="selectedColumns"
- max-height="500"
- border
- :data="modalData.selectedData"
- >
- <template slot="selectedSetSlot" slot-scope="{ row, index }">
- <a
- style="margin: 0 5px; color: red"
- @click="handleSelectedDele(row, index)"
- >删除</a
- >
- </template>
- </Table>
- </div>
- </div>
- </Modal>
- <Modal
- v-model="showProjectModal"
- title="选择项目"
- width="80"
- @on-ok="handleProjectSelect"
- @on-cancel="showProjectModal = false"
- >
- <div class="modal_content">
- <div class="modal_content_center">
- <div class="modal_content_center_top">
- <span>项目名称:</span>
- <Input
- type="text"
- v-model="modalProjectData.title"
- style="width: 180px"
- placeholder="请输入物料名称"
- />
- <Button
- @click="initProjectModal()"
- type="primary"
- style="margin: 0 10px"
- >搜索</Button
- >
- </div>
- <div class="modal_content_center_body">
- <Table
- :columns="modalProjectTableColumns"
- height="520"
- border
- :loading="modalProjectTableLoading"
- :data="modalProjectData.tableData"
- >
- <template slot="basicTypeSet" slot-scope="{ row }">
- <div>
- <span
- v-for="item in warningList"
- :key="item.id"
- :style="{ color: item.color }"
- v-show="item.id == row.warning_state"
- >{{ item.title }}</span
- >
- </div>
- </template>
- </Table>
- <div class="modal_content_center_footer">
- <Page
- :page-size-opts="[10, 20, 30, 40, 100]"
- @on-page-size-change="changeProjectModalSize"
- @on-change="changeProjectModalPage"
- :current="modal_project_page_index"
- show-total
- :total="modal_project_total"
- show-sizer
- :page-size="modal_project_page_size"
- />
- </div>
- </div>
- </div>
- </div>
- </Modal>
- </div>
- </template>
- <script>
- // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
- // 例如:import 《组件名称》 from '《组件路径》';
- export default {
- name: "",
- components: {},
- props: {},
- // import引入的组件需要注入到对象中才能使用
- data() {
- // 这里存放数据
- return {
- searchData: {
- type_id: "",
- time: null,
- remark: "",
- },
- purchaseTypeList: [],
- tableColumns: [
- {
- title: "物料分类",
- key: "type_title",
- align: "center",
- minWidth: 120,
- slot: "materiel_sort",
- },
- {
- title: "物料名称",
- key: "title",
- align: "center",
- minWidth: 140,
- slot: "materiel_name",
- },
- {
- title: "物料规格",
- key: "model",
- align: "center",
- minWidth: 100,
- // render: (h, params) => {
- // const { row } = params
- // let text = `${row.long ? row.long : 0}*${row.width ? row.width : 0}*${row.high ? row.high : 0}`
- // return h('span', {
- // }, text)
- // },
- slot: "materiel_specs",
- },
- { title: "计量单位", key: "unit", align: "center", minWidth: 100 },
- {
- title: "请购数量",
- key: "num",
- align: "center",
- minWidth: 100,
- slot: "numberSet",
- },
- {
- title: "预计到货时间",
- key: "time",
- align: "center",
- minWidth: 180,
- slot: "arrive_timeSet",
- },
- {
- title: "建议供应商",
- key: "supply_id",
- align: "center",
- minWidth: 180,
- transfer: true,
- slot: "supply_idSet",
- },
- {
- title: "操作",
- key: "code",
- align: "center",
- minWidth: 80,
- slot: "setSlot",
- },
- ],
- tableData: [],
- showModal: false,
- showProjectModal: false,
- modalData: {
- title: "",
- tableData: [{}],
- selectedData: [],
- treeData: [
- {
- title: "物料分类",
- expand: true,
- list: [],
- render: (h, { root, node, data }) => {
- return h(
- "span",
- {
- style: {
- display: "inline-block",
- width: "100%",
- },
- },
- [
- h("span", [
- h("Icon", {
- props: {
- type: "ios-folder-outline",
- },
- style: {
- marginRight: "8px",
- },
- }),
- h("span", data.title),
- ]),
- h("span", {
- style: {
- display: "inline-block",
- // float: 'right',
- marginRight: "32px",
- },
- }),
- ]
- );
- },
- },
- ],
- },
- modalProjectData: {
- title: "",
- tableData: [{}],
- },
- suppliersList: [],
- selectedColumns: [
- { title: "物料名称", key: "title", align: "center", minWidth: 110 },
- {
- title: "操作",
- key: "title",
- align: "center",
- minWidth: 90,
- slot: "selectedSetSlot",
- },
- ],
- modalTableLoading: false,
- modalProjectTableLoading: false,
- modal_page_index: 1,
- modal_page_size: 10,
- modal_total: 0,
- modal_project_page_index: 1,
- modal_project_page_size: 10,
- modal_project_total: 0,
- modalTableColumns: [
- { title: "全选", type: "selection", align: "center", minWidth: 60 },
- { title: "物料名称", key: "title", align: "center", minWidth: 110 },
- { title: "物料规格", key: "model", align: "center", minWidth: 110 },
- { title: "计量单位", key: "unit", align: "center", minWidth: 110 },
- ],
- currentChoose: {},
- modalProjectTableColumns: [
- {
- title: "选择",
- key: "",
- align: "center",
- minWidth: 60,
- render: (h, params) => {
- let id = params.row.id;
- let flag = false;
- if (this.currentChoose.id == id) {
- flag = true;
- } else {
- flag = false;
- }
- let self = this;
- return h("div", [
- h("Radio", {
- props: {
- value: flag,
- },
- on: {
- "on-change": () => {
- self.currentChoose = params.row;
- },
- },
- }),
- ]);
- },
- },
- {
- title: "项目名称",
- key: "residential_name",
- align: "center",
- minWidth: 100,
- },
- {
- title: "紧急程度",
- align: "center",
- key: "warning_state",
- minWidth: 80,
- slot: "basicTypeSet",
- },
- // {
- // title: '紧急程度', key: 'state', align: 'center', minWidth: 80,
- // render: (h, params) => {
- // const { row } = params
- // const text = row.state == 1 ? '不急' : row.state == 2 ? '比较急' : row.state == 3 ? '紧急' : '非常急'
- // return h('span', {}, text)
- // }
- // },
- {
- title: "创建时间",
- key: "crt_time",
- align: "center",
- minWidth: 110,
- render: (h, params) => {
- const { row } = params;
- return h("span", {}, this.func.replaceDate(row.crt_time));
- },
- },
- ],
- warehouseTotal: [],
- warehouse: '',
- isCheck: false,
- warningList: [],
- };
- },
- // 生命周期 - 创建完成(可以访问当前this实例)
- created() {
- this.$route.query.type == 2
- ? (this.isCheck = true)
- : (this.isCheck = false);
- // 获取采购类型
- this.axios({ method: "get", url: "/api/basic_purchase_list" })
- .then((res) => {
- this.purchaseTypeList = res.data.data;
- })
- .catch((err) => {});
- // 获取操作员
- // this.axios('/api/user').then(res => this.salesmanList = res.data.data)
- // 获取基础物料类型
- this.axios({ method: "get", url: "/api/basics_material_index_level" })
- .then((res) => {
- this.modalData.treeData[0].list = res.data;
- })
- .catch((err) => {});
- // 获取供应商列表
- this.axios({ method: "get", url: "/api/supply_list" })
- .then((res) => {
- this.suppliersList = res.data.data;
- })
- .catch((err) => {});
- // 获取项目列表
- // this.axios({ method: 'get', url: '/api/order_index', }).then((res) => {
- // this.modalProjectData.tableData = res.data.data
- // this.modal_project_total = res.data.total
- // }).catch((err) => { });
- // 获取紧急程度
- this.axios.get("/api/warning_list").then((res) => {
- this.warningList = res.data.data;
- });
- this.initModal();
- this.initProjectModal();
- },
- // 生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- if (this.$route.query.purchase_order_apply_no != "") {
- this.initData();
- }
- },
- methods: {
- handleToolShow(index, row) {
- if (this.warehouse) {
- return
- } else {
- this.axios
- .get("/api/warehouse_stock_number", {
- params: {
- material_id: row.material_id,
- material_detail_id: row.material_detail_id,
- },
- })
- .then((res) => {
- this.warehouse= res.data
- });
- }
- // this.warehouse.num = this.warehouseTotal[index].num;
- // this.warehouse.warehouseName = this.warehouseTotal[index].warehouseName
- },
- initData() {
- this.axios({
- method: "get",
- url: "/api/purchase_apply_detail",
- params: {
- purchase_order_apply_no: this.$route.query.purchase_order_apply_no,
- },
- })
- .then((res) => {
- this.tableData = res.data.list;
- this.searchData = res.data;
- this.searchData.time = this.func.replaceDate(res.data.crt_time);
- this.tableData.forEach((element) => {
- element.time = this.func.replaceDate(element.arrive_time);
- element.warehouse_list = []
- });
- // for (let key in this.tableData) {
- // this.axios({
- // method: "get",
- // url: "/api/warehouse_stock_number",
- // params: {
- // material_id: this.tableData[key].material_id,
- // material_detail_id: this.tableData[key].material_detail_id,
- // },
- // }).then((res) => {
- // res.data.forEach((el) => {
- // this.warehouseTotal.push(el);
- // });
- // });
- // }
- // console.log(this.warehouseTotal)
- })
- .catch((err) => {});
- },
- handleTreeSlect(array, row) {
- row.id &&
- this.axios({
- method: "get",
- url: "/api/material_detail_list",
- params: {
- page_index: this.modal_page_index,
- page_size: this.modal_page_size,
- m_id: row.id,
- },
- })
- .then((res) => {
- this.modal_total = res.data.total;
- this.modalData.tableData = res.data.data;
- })
- .catch((err) => {});
- },
- handleSet(type, row, index) {
- this.tableData.splice(index, 1);
- },
- handleSelection(selection, row) {
- this.modalData.selectedData.push(row);
- },
- handleSelectionCancel(selection, row) {
- this.modalData.selectedData.forEach((element, index) => {
- if (element.material_detail_id == row.material_detail_id) {
- this.modalData.selectedData.splice(index, 1);
- }
- });
- },
- handleSelectionAll(selection) {
- this.modalData.selectedData =
- this.modalData.selectedData.concat(selection);
- },
- handleSelectionAllCancel() {
- this.modalData.tableData.forEach((element) => {
- this.modalData.selectedData = this.modalData.selectedData.filter(
- (x) => {
- return x.material_detail_id != element.material_detail_id;
- }
- );
- });
- },
- reselection() {
- this.modalData.selectedData.forEach((element) => {
- this.modalData.tableData.forEach((ele, idx) => {
- if (element.material_detail_id == ele.material_detail_id) {
- this.$nextTick(() => {
- this.$refs.modelTable.$refs.tbody.objData[idx]._isChecked = true;
- this.$forceUpdate();
- });
- }
- });
- });
- },
- changeModalSize(e) {
- this.modal_page_size = e;
- this.initModal();
- },
- changeModalPage(e) {
- this.modal_page_index = e;
- this.initModal();
- },
- changeProjectModalSize(e) {
- this.modal_project_page_size = e;
- this.initProjectModal();
- },
- changeProjectModalPage(e) {
- this.modal_project_page_index = e;
- this.initProjectModal();
- },
- handleSelectedDele(row, index) {
- this.modalData.selectedData.splice(index, 1);
- },
- initModal() {
- this.axios({
- method: "get",
- url: "/api/material_detail_list",
- params: {
- page_index: this.modal_page_index,
- page_size: this.modal_page_size,
- title: this.modalData.title,
- },
- })
- .then((res) => {
- this.modal_total = res.data.total;
- this.modalData.tableData = res.data.data;
- this.reselection();
- })
- .catch((err) => {});
- },
- initProjectModal() {
- this.axios({
- method: "get",
- url: "/api/order_index",
- params: {
- page_index: this.modal_project_page_index,
- page_size: this.modal_project_page_size,
- title: this.modalProjectData.title,
- },
- })
- .then((res) => {
- this.modal_project_total = res.data.total;
- this.modalProjectData.tableData = res.data.data;
- })
- .catch((err) => {});
- },
- handleSelect() {
- this.modalData.selectedData.forEach((element) => {
- element.material_id = element.m_id;
- element.type_title = element.m_title;
- // element.arrive_time = this.func.replaceDate(element.arrive_time)
- element.num = null;
- // element.arrive_time = null
- element.supply_id = null;
- });
- // this.tableData = [...this.tableData, ...this.modalData.selectedData]
- this.tableData.splice(
- this.tableData.length - 1,
- 0,
- ...this.modalData.selectedData
- );
- // console.log('this.modalData.selectedData :>> ', this.modalData.selectedData);
- },
- handleProjectSelect() {
- this.searchData.residential_name = this.currentChoose.residential_name;
- this.searchData.order_no = this.currentChoose.order_no;
- },
- goBack() {
- this.$router.go(-1);
- },
- postData() {
- this.searchData.crt_time =
- parseInt(new Date(this.searchData.time).getTime() / 1000) || "";
- this.tableData.forEach((element) => {
- element.arrive_time =
- parseInt(new Date(element.time).getTime() / 1000) || "";
- });
- let url;
- if (this.$route.query.purchase_order_apply_no == "") {
- url = "/api/purchase_apply_add";
- } else {
- url = "/api/purchase_apply_edit";
- }
- this.axios({
- method: "post",
- url,
- data: {
- ...this.searchData,
- list: this.tableData,
- },
- })
- .then((res) => {
- this.$Message.success(res.msg);
- this.goBack();
- })
- .catch((err) => {});
- },
- },
- // 监听属性 类似于data概念
- computed: {},
- // 监控data中的数据变化
- watch: {},
- beforeCreate() {}, // 生命周期 - 创建之前
- beforeMount() {}, // 生命周期 - 挂载之前
- beforeUpdate() {}, // 生命周期 - 更新之前
- updated() {}, // 生命周期 - 更新之后
- beforeDestroy() {}, // 生命周期 - 销毁之前
- destroyed() {}, // 生命周期 - 销毁完成
- activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='scss' scoped>
- .content_topform {
- padding-top: 20px;
- /deep/.ivu-form {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- flex-wrap: wrap;
- }
- /deep/.ivu-form-item {
- display: inline-block;
- width: 300px;
- }
- }
- .content_table {
- .content_table_btn {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- padding-bottom: 20px;
- }
- }
- .modal_content {
- display: flex;
- justify-content: center;
- overflow: hidden;
- overflow-y: auto;
- .modal_content_left {
- }
- .modal_content_center {
- width: 80%;
- border-left: 1px solid #666;
- border-right: 1px solid #666;
- padding: 0 20px;
- .modal_content_center_top {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- span {
- width: 100px;
- }
- div {
- display: flex;
- justify-content: space-around;
- align-items: center;
- span {
- width: 100px;
- }
- }
- .modal_content_center_body {
- overflow: hidden;
- overflow-y: auto;
- height: 500px;
- }
- }
- .modal_content_center_body {
- padding-top: 20px;
- }
- .modal_content_center_footer {
- display: flex;
- justify-content: center;
- padding-top: 20px;
- }
- }
- .modal_content_right {
- width: 30%;
- padding: 0 20px;
- }
- }
- /deep/ .ivu-table-wrapper {
- overflow: visible;
- } //穿透iview
- </style>
|