123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707 |
- <template>
- <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title + '-列表', essential: true }]">
- <template slot-scope="{ activeKey, data }">
- <template-page
- v-if="activeKey == 'list'"
- ref="pageRef"
- :get-list="getList"
- :table-attributes="tableAttributes"
- :table-events="tableEvents"
- :options-evens-group="optionsEvensGroup"
- :moreParameters="moreParameters"
- :column-parsing="columnParsing"
- :operation="operation()"
- :exportList="exportList"
- :operationColumnWidth="80"
- >
- </template-page>
- <div v-if="~['add', 'edit'].indexOf(activeKey)">
- <div style="box-sizing: border-box; padding: 20px">
- <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
- <zj-form-module title="编辑" label-width="120px" :form-data="formData" :form-items="formItems">
- </zj-form-module>
- <zj-form-module
- v-if="formData.normType === 'M'"
- title="添加辅材"
- label-width="0px"
- :form-data="formData"
- :form-items="formItems2"
- >
- </zj-form-module>
- </zj-form-container>
- </div>
- <div slot="footer" style="box-sizing: border-box; padding-bottom: 20px; padding-right: 20px; text-align: right">
- <el-button size="mini" @click="data.removeTab()">取 消</el-button>
- <el-button size="mini" @click="formConfirm(data.removeTab)" type="primary">确 定</el-button>
- </div>
- <selectGoods
- v-if="formVisible"
- @close="close"
- @confirm="confirm"
- :guolvList="(formData.items || []).map(item => item.workerGoodsId)"
- />
- </div>
- </template>
- </zj-tab-page>
- </template>
- <script>
- import TemplatePage from '@/components/template/template-page-1.vue'
- import import_mixin from '@/components/template/import_mixin.js'
- import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
- import {
- materialNormList,
- materialNormListExport,
- materialNormAdd,
- materialNormEdit,
- materialNormDetail,
- materialNormBatchUpdateStatus,
- materialNormImport2,
- materialNormImport
- } from '@/api/auxiliaryChargeManagement'
- import { materialCategoryTree } from '@/api/auxiliaryMaterialClass'
- import { getTypeList } from '@/api/auxiliaryFittings/attachmentProfile'
- import { commonTemplateDownload } from '@/api/common.js'
- import operation_mixin from '@/components/template/operation_mixin.js'
- import selectGoods from './selectGoods.vue'
- export default {
- components: { TemplatePage, selectGoods },
- mixins: [import_mixin, operation_mixin],
- data() {
- return {
- // 表格属性
- tableAttributes: {
- // 启用勾选列
- selectColumn: true
- },
- // 表格事件
- tableEvents: {
- 'selection-change': this.selectionChange
- },
- // 勾选选中行
- recordSelected: [],
- /** 表单变量 */
- formDialogType: 0,
- formDialogTitles: ['新增', '编辑'],
- formDialog: false,
- formData: {
- companyWechatName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
- categoryId: '',
- companyWechatId: '',
- createBy: '',
- createTime: '',
- normAmount: 0,
- normCode: '',
- normId: '',
- normName: '',
- normType: '',
- outWebsitAmount: 0,
- outWorkerAmount: 0,
- parentCategoryId: '',
- remark: '',
- selfWebsitAmount: 0,
- selfWorkerAmount: 0,
- specification: '',
- status: 'ON',
- unit: '',
- manualAmount: 0,
- items: []
- },
- partsUnitList: [],
- materialCategoryTree: [],
- formType: 'add',
- formVisible: false
- }
- },
- computed: {
- // 事件组合
- optionsEvensGroup() {
- return [
- [
- [
- this.optionsEvensAuth('add', {
- click: () => {
- this.openForm('add')
- }
- })
- ],
- [
- this.optionsEvensAuth(['imp', 'template'], {
- name: '导入物料',
- click: () => {}
- }),
- this.optionsEvensAuth('imp', ({ moduleName }) => {
- return {
- name: moduleName,
- render: () => {
- return this.importButton(materialNormImport, moduleName)
- }
- }
- }),
- this.optionsEvensAuth('template', {
- click: () => {
- commonTemplateDownload({ name: '辅材收费标准模板(物料收费).xlsx' }, `辅材收费标准模板(物料收费)`)
- .then(res => {
- this.$message({
- message: '下载成功',
- type: 'success'
- })
- })
- .catch(err => {
- this.$message.error('下载失败')
- })
- }
- })
- ],
- [
- this.optionsEvensAuth(['Import', 'downloadTemplate'], {
- name: '导入服务',
- click: () => {}
- }),
- this.optionsEvensAuth('Import', ({ moduleName }) => {
- return {
- name: moduleName,
- render: () => {
- return this.importButton(materialNormImport2, moduleName)
- }
- }
- }),
- this.optionsEvensAuth('downloadTemplate', {
- click: () => {
- commonTemplateDownload({ name: '辅材收费标准模板(服务收费).xlsx' }, `辅材收费标准模板(服务收费)`)
- .then(res => {
- this.$message({
- message: '下载成功',
- type: 'success'
- })
- })
- .catch(err => {
- this.$message.error('下载失败')
- })
- }
- })
- ]
- ],
- [
- [
- this.optionsEvensAuth('batchLaunch', {
- click: () => {
- if (this.recordSelected.length) {
- this.setRowStatus('ON')
- } else {
- this.$message({
- type: 'warning',
- message: `请先勾选需要设置的数据!`
- })
- }
- }
- })
- ],
- [
- this.optionsEvensAuth('batchRemoval', {
- click: () => {
- if (this.recordSelected.length) {
- this.setRowStatus('OFF')
- } else {
- this.$message({
- type: 'warning',
- message: `请先勾选需要设置的数据!`
- })
- }
- }
- })
- ]
- ]
- ]
- },
- // 更多参数
- moreParameters() {
- return []
- },
- formItems() {
- return [
- {
- md: 6,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入', disabled: true },
- formItemAttributes: {
- label: '所属商户',
- prop: 'companyWechatName',
- rules: [...required]
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'el-radio',
- options: [
- { label: '上架', value: 'ON' },
- { label: '下架', value: 'OFF' }
- ],
- attributes: {},
- formItemAttributes: {
- label: '状态',
- prop: 'status',
- rules: [...required]
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'el-cascader',
- attributes: {
- style: 'width:100%',
- placeholder: '请输入',
- options: this.materialCategoryTree,
- 'show-all-levels': false,
- props: { value: 'categoryId', label: 'categoryName', children: 'child', emitPath: false },
- clearable: true
- },
- formItemAttributes: {
- label: '选择分类',
- prop: 'categoryId',
- rules: [...required]
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入' },
- formItemAttributes: {
- label: '辅材名称',
- prop: 'normName',
- rules: [...required]
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'el-select-add',
- labelKey: 'dictValue',
- valueKey: 'dictValue',
- options: this.partsUnitList,
- attributes: { placeholder: '请选择单位', filterable: true, clearable: true },
- formItemAttributes: {
- label: '单位',
- prop: 'unit',
- rules: [...required]
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入' },
- formItemAttributes: {
- label: '商品代码',
- prop: 'normCode',
- rules: []
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入' },
- formItemAttributes: {
- label: '规格型号',
- prop: 'specification',
- rules: []
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'el-radio',
- options: [
- { label: '物料收费', value: 'M' },
- { label: '服务收费', value: 'S' }
- ],
- attributes: {},
- formItemAttributes: {
- label: '收费类型',
- prop: 'normType',
- rules: [...required]
- },
- events: {
- change: () => {
- this.formData.items = []
- }
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入', type: 'number' },
- formItemAttributes: {
- label: '收费标准',
- prop: 'normAmount',
- rules: [...required]
- },
- events: {
- input: val => {
- this.formData.selfWorkerAmount = ''
- this.formData.outWorkerAmount = ''
- this.$nextTick(() => {
- this.formData.selfWebsitAmount = this.setNumber(
- this.formData.normAmount - (this.formData.selfWorkerAmount || 0)
- )
- this.formData.outWebsitAmount = this.setNumber(
- this.formData.normAmount - (this.formData.outWorkerAmount || 0)
- )
- })
- }
- }
- },
- {
- md: 6,
- isShow: true,
- name: 'slot-component',
- attributes: { placeholder: '请输入' },
- formItemAttributes: {
- label: '',
- prop: '',
- 'label-width': '0px'
- },
- render: (h, { props, onInput }) => {
- var { value } = props
- return <div style="color:red">注:分账金额需扣除手续费0.6%</div>
- }
- },
- // {
- // md: 6,
- // isShow: true,
- // name: 'el-input',
- // attributes: { placeholder: '请输入', type: 'number', disabled: !this.formData.normAmount },
- // formItemAttributes: {
- // label: '自有库存师傅(分账金额)',
- // prop: 'selfWorkerAmount',
- // rules: [...required]
- // },
- // events: {
- // input: val => {
- // if (Number(val) > this.formData.normAmount) {
- // this.formData.selfWorkerAmount = this.setNumber(this.formData.normAmount)
- // }
- // this.formData.selfWebsitAmount = this.setNumber(this.formData.normAmount - this.formData.selfWorkerAmount)
- // }
- // },
- // slots: {
- // append: (h, { props, onInput }) => {
- // return <div>元</div>
- // }
- // }
- // },
- // {
- // md: 6,
- // isShow: true,
- // name: 'el-input',
- // attributes: { placeholder: '请输入', type: 'number', disabled: !this.formData.normAmount },
- // formItemAttributes: {
- // label: '外购辅材师傅(分账金额)',
- // prop: 'outWorkerAmount',
- // rules: [...required]
- // },
- // events: {
- // input: val => {
- // if (Number(val) > this.formData.normAmount) {
- // this.formData.outWorkerAmount = this.setNumber(this.formData.normAmount)
- // }
- // this.formData.outWebsitAmount = this.setNumber(this.formData.normAmount - this.formData.outWorkerAmount)
- // }
- // },
- // slots: {
- // append: (h, { props, onInput }) => {
- // return <div>元</div>
- // }
- // }
- // },
- // {
- // md: 6,
- // isShow: true,
- // name: 'el-input',
- // attributes: { placeholder: '请输入', disabled: true, type: 'number' },
- // formItemAttributes: {
- // label: '自有库存商户(分账金额)',
- // prop: 'selfWebsitAmount',
- // rules: [...required]
- // },
- // slots: {
- // append: (h, { props, onInput }) => {
- // return <div>元</div>
- // }
- // }
- // },
- // {
- // md: 6,
- // isShow: true,
- // name: 'el-input',
- // attributes: { placeholder: '请输入', disabled: true, type: "number", },
- // formItemAttributes: {
- // label: '外购辅材商户(分账金额)',
- // prop: 'outWebsitAmount',
- // rules: [...required]
- // },
- // slots: {
- // append: (h, { props, onInput }) => {
- // return <div>元</div>
- // }
- // }
- // },
- // {
- // md: 6,
- // isShow: true,
- // name: 'el-input',
- // attributes: { placeholder: '请输入', type: 'number' },
- // formItemAttributes: {
- // label: '师傅手工费用',
- // prop: 'manualAmount',
- // rules: [...required]
- // }
- // },
- {
- md: 24,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入', type: 'textarea', rows: 5 },
- formItemAttributes: {
- label: '备注',
- prop: 'remark',
- rules: []
- }
- }
- ]
- },
- formItems2() {
- return [
- {
- name: 'slot-component',
- md: 24,
- formItemAttributes: {
- 'label-width': '0px',
- label: '',
- prop: 'items',
- rules: [...required]
- },
- render: (h, { props }) => {
- return (
- <div>
- <div>
- <el-button
- size="mini"
- type="primary"
- onClick={() => {
- this.formVisible = true
- }}
- >
- 新增
- </el-button>
- </div>
- <zj-table
- columns={[
- {
- columnAttributes: {
- label: '大类名称',
- prop: 'parentCategoryName'
- }
- },
- {
- columnAttributes: {
- label: '小类名称',
- prop: 'goodsCategoryName'
- }
- },
- {
- columnAttributes: {
- label: '辅材名称',
- prop: 'workerGoodsName'
- }
- },
- {
- columnAttributes: {
- label: '单位',
- prop: 'salesUnit'
- }
- },
- {
- columnAttributes: {
- label: '商品代码',
- prop: 'goodsCode'
- }
- },
- {
- columnAttributes: {
- label: '数量',
- prop: 'qty',
- width: 150
- },
- render: (h, { row, column, index }) => {
- return (
- <div style="padding: 0 10px">
- <el-input
- value={row[column.columnAttributes.prop]}
- onInput={val => {
- row[column.columnAttributes.prop] = val
- }}
- placeholder="请输入内容"
- ></el-input>
- </div>
- )
- }
- },
- {
- columnAttributes: {
- label: '操作',
- prop: ''
- },
- render: (h, { row, column, index }) => {
- return (
- <div style="padding: 0 10px">
- <el-button
- size="mini"
- type="text"
- onClick={() => {
- this.formData.items.splice(index, 1)
- }}
- >
- 删除
- </el-button>
- </div>
- )
- }
- }
- ]}
- table-data={this.formData.items || []}
- />
- </div>
- )
- }
- }
- ]
- }
- },
- methods: {
- // 列表请求函数
- getList: materialNormList,
- // 列表导出函数
- exportList: materialNormListExport,
- // 表格列解析渲染数据更改
- columnParsing(item, defaultData) {
- return defaultData
- },
- // 监听勾选变化
- selectionChange(data) {
- this.recordSelected = data
- },
- operation() {
- return this.operationBtn({
- edit: {
- click: ({ row, index, column }) => {
- this.openForm('edit', row.normId)
- }
- }
- })
- },
- openForm() {},
- openForm(type, id) {
- this.$refs.tabPage.addTab({
- // 对应显示的模块
- activeKey: type,
- // 唯一标识
- key: type,
- // 页签名称
- label: { edit: '编辑', add: '新增' }[type],
- // 打开时事件
- triggerEvent: () => {
- this.formCancel()
- this.$nextTick(() => {
- this.formType = type
- Promise.all([
- getTypeList({
- pageNum: 1,
- pageSize: -1,
- params: [
- { param: 'a.dict_type', compare: '=', value: `ASSIST_UNIT` },
- { param: 'a.status', compare: '=', value: 'ON' }
- ]
- }),
- materialCategoryTree({ state: 'ON' })
- ]).then(([res1, res2]) => {
- this.partsUnitList = res1.data.records
- this.materialCategoryTree = res2.data.filter(item => item.child && item.child.length > 0)
- this.formDialog = true
- })
- if (type == 'add') {
- this.formDialogType = 0
- } else if (type == 'edit') {
- this.formDialogType = 1
- materialNormDetail({ id }).then(res => {
- Object.assign(this.formData, res.data)
- })
- }
- })
- },
- // 关闭时事件
- closeEvent: () => {
- this.formCancel()
- }
- })
- },
- formCancel() {
- this.formVisible = false
- this.$refs?.formRef?.resetFields()
- this.$data.formData = this.$options.data().formData
- },
- formConfirm(cancel) {
- this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
- if (valid) {
- ;[materialNormAdd, materialNormEdit][this.formDialogType](this.formData).then(res => {
- this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
- cancel('list')
- this.$refs.pageRef.refreshList()
- })
- }
- })
- },
- setRowStatus(type) {
- materialNormBatchUpdateStatus({
- ids: this.recordSelected.map(item => item.normId).join(','),
- stateEnum: type
- }).then(res => {
- this.$message({ type: 'success', message: `设置成功!` })
- this.$refs.pageRef.refreshList()
- })
- },
- setNumber(val) {
- return Number(val.toFixed(2))
- },
- close() {
- this.formVisible = false
- },
- confirm(data) {
- data
- .filter(val => !~this.formData.items.map(item => item.workerGoodsId).indexOf(val.goodsId))
- .map(item => {
- this.formData.items.push({
- goodsCategoryId: item.categoryId,
- goodsCategoryName: item.categoryName,
- goodsCode: item.goodsCode,
- salesUnit: item.salesUnit,
- parentCategoryId: item.parentCategoryId,
- parentCategoryName: item.parentCategoryName,
- workerGoodsId: item.goodsId,
- workerGoodsName: item.goodsName,
- qty: ''
- })
- })
- this.close()
- }
- }
- }
- </script>
- <style lang="scss" scoped></style>
|