123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- <template>
- <div>
- <h3>{{ title }}</h3>
- <el-divider />
- <div style="margin-bottom: 20px; width: 80px">
- <el-button v-if="!['detail', 'examine'].includes(module)" type="primary" size="small" @click="handleAdd"
- >添加机型</el-button
- >
- </div>
- <zj-table
- ref="tableEl"
- :is-drop="true"
- :columns="columns"
- :table-data="formData.items"
- :table-attributes="{
- border: true,
- maxHeight: 600
- }"
- />
- <el-dialog title="添加机型" append-to-body :visible.sync="isShowDialog" width="70%" :append-to-body="true">
- <el-form ref="screenForm" :model="screenForm" size="small" label-position="left">
- <el-row :gutter="20">
- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item prop="name">
- <el-input v-model="screenForm.name" placeholder="物料名称"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item prop="number">
- <el-input v-model="screenForm.number" placeholder="物料编码"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item prop="oldNumber">
- <el-input v-model="screenForm.oldNumber" placeholder="产品编码"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item prop="specification">
- <el-input v-model="screenForm.specification" placeholder="规格型号"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="24" class="tr">
- <el-form-item label="">
- <el-button size="small" @click="resetScreenForm">清空</el-button>
- <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div class="table">
- <zj-table
- ref="tableEl"
- :is-drop="true"
- :columns="columns2"
- :table-data="k3List"
- :table-attributes="{
- border: true,
- selectColumn: true,
- selectable: this.selectable
- }"
- :tableEvents ="{
- 'selection-change': this.selectionChange
- }"
- />
- <div class="pagination clearfix" style="margin-top: 10px">
- <div class="fr">
- <el-pagination
- @current-change="handleTableCurrentChange"
- :current-page="currentPage"
- :page-size="10"
- background
- layout="prev, pager, next"
- :total="listTotal"
- >
- </el-pagination>
- </div>
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="closeDialog">取 消</el-button>
- <el-button type="primary" @click="submitAddGoods">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getMaterialListV2 } from '@/api/basic_data/material'
- export default {
- props: {
- title: {
- type: String,
- default: '机型信息'
- },
- formData: {
- type: Object,
- default: () => ({})
- },
- // 页面类型
- pageType: {
- type: String,
- default: 'frock'
- },
- // 功能类型
- module: {
- type: String,
- default: 'add'
- },
- commonData: {
- type: Object,
- default: () => {}
- }
- },
- data() {
- return {
- loading: false,
- k3List: [],
- isShowDialog: false,
- currentPage: 1,
- pageSize: 10,
- listTotal: 0,
- screenForm: {
- name: '',
- oldNumber: '',
- number: '',
- specification: ''
- },
- recordSelected: []
- }
- },
- computed: {
- columns() {
- return [
- ...(() => {
- return !['detail', 'examine'].includes(this.module)
- ? [
- {
- hidden: '',
- columnAttributes: {
- fixed: 'left',
- label: '操作',
- prop: ''
- },
- render: (h, { row, column, index }) => {
- return (
- <div>
- <el-button
- size="mini"
- type="text"
- onClick={() => {
- this.formData.items.splice(index, 1)
- }}
- >
- 删除
- </el-button>
- </div>
- )
- }
- }
- ]
- : []
- })(),
- {
- columnAttributes: {
- label: '物料名称*',
- prop: 'materialName'
- },
- render: (h, { row, column, index }) => {
- return (
- <div style="display:flex;justify-content: space-between;align-items: center;">
- <div> {row.materialName}</div>
- <CopyButton copyText={row.materialName} />
- </div>
- )
- }
- },
- {
- columnAttributes: {
- label: '规格型号*',
- prop: 'specification'
- },
- render: (h, { row, column, index }) => {
- return (
- <div style="display:flex;justify-content: space-between;align-items: center;">
- <div> {row.specification}</div>
- <CopyButton copyText={row.specification} />
- </div>
- )
- }
- },
- {
- columnAttributes: {
- label: '备注',
- prop: 'itemRemark'
- },
- render: (h, { row, column, index }) => {
- return (
- <div>
- <el-input
- style="padding: 5px;width:90%"
- value={row.itemRemark}
- onInput={e => (row.itemRemark = e)}
- placeholder="请输入备注"
- size="mini"
- clearable
- >
- </el-input>
- <CopyButton copyText={row.itemRemark} />
- </div>
- )
- }
- },
- {
- columnAttributes: {
- label: '数量*',
- prop: 'qty'
- },
- render: (h, { row, column, index }) => {
- return (
- <el-input
- style="padding: 5px;"
- type="number"
- value={row.qty}
- placeholder="请输入数量"
- min={1}
- onInput={e => (row.qty = e)}
- size="mini"
- clearable
- ></el-input>
- )
- }
- }
- ]
- },
- columns2() {
- return [
- {
- columnAttributes: {
- label: '物料名称',
- prop: 'name',
- width: 200
- }
- },
- {
- columnAttributes: {
- label: '物料编码',
- prop: 'number',
- width: 100
- }
- },
- {
- columnAttributes: {
- label: '旧物料编码',
- prop: 'oldNumber',
- width: 100
- }
- },
- {
- columnAttributes: {
- label: '规格型号',
- prop: 'specification'
- }
- }
- ]
- }
- },
- methods: {
- getMaterialListV2() {
- const params = []
- Object.keys(this.screenForm).forEach(k => {
- if (this.screenForm[k]) {
- params.push({
- param: `a.${k}`,
- compare: 'like',
- value: this.screenForm[k]
- })
- }
- })
- getMaterialListV2({
- pageNum: this.currentPage,
- pageSize: this.pageSize,
- params
- }).then(res => {
- this.k3List = res.data.records
- this.listTotal = res.data.total
- this.loading = false
- })
- },
- remoteMethod(query, type, name) {
- if (query !== '') {
- this.loading = true
- getMaterialListV2({
- pageNum: 1,
- pageSize: 100,
- params: [
- {
- param: `a.${type}`,
- compare: 'like',
- value: query
- }
- ]
- }).then(res => {
- this.k3List = res.data.records
- this.loading = false
- })
- } else {
- this.k3List = []
- }
- },
- setCheckeData(e, row) {
- if (e) {
- const item = this.k3List.find(k => k.id === e)
- row.specification = item.specification
- row.materialName = item.name
- row.materialId = item.id
- row.materialOldNumber = item.oldNumber
- } else {
- row.specification = ''
- row.materialName = ''
- row.materialId = ''
- row.materialOldNumber = ''
- }
- },
- handleAdd() {
- this.getMaterialListV2()
- this.isShowDialog = true
- // this.formData.items.push({
- // id: '',
- // itemRemark: '',
- // materialId: '',
- // materialName: '',
- // materialNumber: '',
- // materialOldNumber: '',
- // orderId: '',
- // projectNo: '',
- // qty: null,
- // specification: '',
- // unit: ''
- // })
- },
- selectable(row,index){
- for (let i = 0; i < this.formData.items.length; i++) {
- if (this.formData.items[i].materialId == row.id) {
- row.disabled = true
- }
- }
- if(row.disabled){
- return false
- }else{
- return true
- }
- },
- // 监听勾选变化
- selectionChange(data) {
- this.recordSelected = data
- },
- closeDialog() {
- this.isShowDialog = false
- },
- submitAddGoods() {
- this.formData.items =[ ...this.formData.items, ...this.recordSelected.map(k=>{
- return {
- qty: null,
- unit: '',
- orderId: '',
- projectNo: '',
- itemRemark: '',
- specification : k.specification,
- materialName : k.name,
- materialId : k.id,
- materialOldNumber : k.oldNumber,
- }
- })]
- this.k3List= []
- this.isShowDialog = false
- },
- // 更改列表当前页
- handleTableCurrentChange(val) {
- this.currentPage = val
- this.getMaterialListV2()
- },
- // 提交筛选表单
- submitScreenForm() {
- this.currentPage = 1
- this.getMaterialListV2()
- },
- // 重置筛选表单
- resetScreenForm() {
- this.$refs.screenForm.resetFields()
- this.currentPage = 1
- this.getMaterialListV2()
- }
- }
- }
- </script>
- <style lang="scss" scoped></style>
|