123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- <template>
- <div>
- <!-- <add-product ref="addpro" :data="data" @onConfirm="listData"></add-product>-->
- <addTool ref="addTool" :params="paramsAdd" :tablecolsAdd="tablecolsAdd" title="添加" @addSuccess="addTools"
- @addProduct="addTool" @uploadData="uploadData" @closeDrawer="listData();$emit('onSuccess')"
- class="inline-16 normal-margin" v-if="data.status === '新建'"
- ></addTool>
- <uploadAllData
- v-if="data.status === '新建'"
- class="inline-16 normal-margin"
- :total="total"
- @onSuccess="listData();$emit('onSuccess')"
- @handlePullApi="handlePullApi"
- @handleDelApi="handleDelApi"
- idName="sa_orderitemsid"
- type="del"
- ></uploadAllData>
- <excel style="margin:0 0 10px 10px" :tablecols="columnTitle" :param="param" :total="total" :excelTitle="excelTitle"></excel>
- <el-table
- ref="multipleTable"
- :data="tableData"
- height="500px"
- style="width: 100%;"
- size="small"
- stripe
- border>
- <el-table-column
- prop="itemname"
- label="产品名称"
- fixed
- width="180">
- </el-table-column>
- <el-table-column
- prop="itemno"
- label="产品编号"
- width="180">
- </el-table-column>
- <el-table-column
- label="型号"
- width="150"
- prop="model">
- <template slot-scope="scope">
- <p><span>{{scope.row.model}}</span></p>
- </template>
- </el-table-column>
- <el-table-column
- label="规格"
- width="150"
- prop="spec">
- <template slot-scope="scope">
- <p><span>{{scope.row.spec}}</span></p>
- </template>
- </el-table-column>
- <el-table-column
- label="数量"
- width="180"
- prop="qty">
- <template slot-scope="scope">
- <el-input-number :controls="true" controls-position='right' :step-strictly="true" v-if="type === 'edit' && !data.sa_contractid" size="mini" v-model="scope.row.qty" :min="scope.row.orderminqty" :step="scope.row.orderaddqty" label="输入数量" @change="rowChange(scope.row,scope.$index)"></el-input-number>
- <span v-else>{{scope.row.qty}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="needdate"
- label="需求日期"
- width="180">
- <template slot="header" slot-scope="scope">
- <div>
- <el-date-picker
- style="width:150px"
- v-if="type === 'edit'"
- v-model="value2"
- value-format="yyyy-MM-dd"
- slot="reference"
- align="right"
- type="date"
- size="mini"
- placeholder="一键交期"
- @change="dateChangeNeed">
- </el-date-picker>
- <span v-else>需求日期</span>
- </div>
- </template>
- <template slot-scope="scope">
- <el-date-picker
- v-if="scope.row.delivery > 0 && type === 'edit'"
- v-model="scope.row.needdate"
- type="date"
- placeholder="选择日期"
- value-format="yyyy-MM-dd"
- size="mini"
- style="width:150px"
- :picker-options="pickerOptions"
- @change="rowChange(scope.row)"
- @focus="setPickerOptions(scope.row)">
- </el-date-picker>
- <div v-else>
- <p v-if="scope.row.delivery === 0 ">不管控交期</p>
- <p v-else>{{scope.row.needdate}}</p>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="回复交期"
- width="200"
- prop="deliverydate">
- <template slot="header" slot-scope="scope">
- <div>
- <el-date-picker
- style="width:180px"
- v-if="type === 'confirmdate'"
- v-model="value2"
- value-format="yyyy-MM-dd"
- slot="reference"
- align="right"
- type="date"
- size="mini"
- placeholder="一键交期"
- @change="dateChange">
- </el-date-picker>
- <span v-else>回复交期</span>
- </div>
- </template>
- <template slot-scope="scope">
- <el-date-picker
- v-if="scope.row.delivery > 0 && type === 'confirmdate'"
- v-model="scope.row.deliverydate"
- type="date"
- placeholder="选择日期"
- value-format="yyyy-MM-dd"
- size="mini"
- style="width:150px"
- :picker-options="pickerOptions"
- @change="onDateChange(scope.row)"
- @focus="setPickerOptions(scope.row)">
- </el-date-picker>
- <div v-else>
- <p v-if="scope.row.delivery === 0 ">不管控交期</p>
- <p v-else>{{scope.row.deliverydate}}</p>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- prop="unit"
- label="计量单位"
- width="90">
- <template slot-scope="scope">
- <el-tag size="mini" type="info" effect="plain">{{scope.row.unit}}</el-tag>
- </template>
- </el-table-column>
- <el-table-column
- prop="price"
- label="价格"
- width="100">
- <template slot-scope="scope">
- <p style="color:red;font-weight:500">¥ {{tool.formatAmount(scope.row.price,2)}}</p>
- </template>
- </el-table-column>
- <el-table-column
- label="小计"
- prop="deliverydate">
- <template slot-scope="scope">
- <p style="color:red;font-weight:500">¥ {{tool.formatAmount(scope.row.price * scope.row.qty,2)}}</p>
- </template>
- </el-table-column>
- <el-table-column
- label="备注"
- width="300"
- prop="remarks">
- <template slot-scope="scope">
- <el-input v-if="type === 'edit'" v-model="scope.row.remarks" placeholder="输入订单备注" size="mini" @change="rowChange(scope.row,scope.$index)"></el-input>
- <p v-else>{{scope.row.remarks}}</p>
- </template>
- </el-table-column>
- <el-table-column v-if="!data.sa_contractid" width="90" fixed="right">
- <template slot-scope="scope">
- <el-button v-if="tool.checkAuth($route.name,'billDetail')" type="text" size="mini" @click="deleteOrderProduct(scope.row)">删 除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="margin-top:16px;text-align:right">
- <el-pagination
- background
- small
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-size="param.content.pageSize"
- layout="total, prev, pager, next, jumper"
- :total="total">
- </el-pagination>
- </div>
- </div>
- </template>
- <script>
- import addProduct from '@/template/toolBorrowingCanUseProduct/index.vue'
- import addTool from '@/template/addTool/index'
- import uploadAllData from '@/components/uploadAllData/index'
- import excel from '@/HDrpManagement/orderManage/details/export_excel'
- export default {
- props:['data','type'],
- data () {
- return {
- dataRefresh:true,
- tableData:[],
- tablecolsAdd:[],
- columnTitle:[],
- excelTitle:'借用单明细',
- param:{
- "id": 20230116104102,
- "content": {
- "sa_orderid": 0, //订单ID
- "pageNumber": 1,
- "pageSize": 20,
- "where": {
- "condition": ""
- }
- },
- },
- paramsAdd:{
- "id": 20230116111602,
- "content": {
- "sa_orderid": this.$route.query.id,
- "pageNumber": 1,
- "pageSize": 100,
- "where": {
- "condition": ""
- }
- },
- },
- pickerOptions: {
- disabledDate(time) {
- return time.getTime() < (Date.now() - 24 * 3600 * 1000);
- },
- },
- total:0,
- currentPage:0,
- time: null,
- value2:''
- }
- },
- components:{
- addProduct,addTool,uploadAllData,excel
- },
- methods:{
- async listData () {
- this.param.content.sa_orderid = this.$route.query.id
- const res = await this.$api.requested(this.param)
- this.tableData = res.data
- this.total = res.total
- this.currentPage = res.pageNumber
- this.$emit('queryDetail')
- },
- handleSizeChange(val) {
- // console.log(`每页 ${val} 条`);
- this.params.content.pageSize = val
- this.listData()
- },
- handleCurrentChange(val) {
- // console.log(`当前页: ${val}`);
- this.params.content.pageNumber = val
- this.listData()
- },
- async deleteOrderProduct (row) {
- const res = await this.$api.requested({
- "id": 20221109093702,
- "content": {
- "sa_orderid":this.$route.query.id,
- "sa_orderitemsids": [row.sa_orderitemsid]
- },
- })
- this.tool.showMessage(res,()=>{
- this.listData()
- this.$emit('onSuccess')
- })
- },
- rowChange (val,index) {
- let that = this
- this.$set(this.tableData,index,val)
- // // 防抖
- if(this.time !== null){
- clearTimeout(this.time);
- }
- this.time = setTimeout(() => {
- that.updateOrder({
- "sa_orderid": this.data.sa_orderid, //订单ID
- "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
- "sa_contractid": this.data.contacts.contactsid, //合同ID
- "type": this.data.type, //订单类型
- "items": [{
- "sa_orderitemsid": val.sa_orderitemsid,//0表示新增
- "itemid": val.itemid, //商品ID
- "qty": val.qty, //数量
- "needdate": val.needdate,//可以不传,修改交期
- "price":val.price,
- "remarks":val.remarks
- }]
- })
- },500)
- },
- onDateChange (val){
- let that = this
- that.updateOrder({
- "sa_orderid": this.data.sa_orderid, //订单ID
- "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
- "sa_contractid": this.data.contacts.contactsid, //合同ID
- "type": this.data.type, //订单类型
- "items": [{
- "sa_orderitemsid": val.sa_orderitemsid,//0表示新增
- "itemid": val.itemid, //商品ID
- "qty": val.qty, //数量
- "deliverydate": val.deliverydate//可以不传,修改交期
- }]
- })
- },
- async dateChangeNeed(val){
- // const res = await this.$api.requested({
- // "id": 20230104143802,
- // "content": {
- // "sa_orderid": this.data.sa_orderid,
- // "needdate": this.value2
- // },
- // })
- },
- async updateOrder (val) {
- const res = await this.$api.requested({
- "id": 20230116101602,
- "content": val
- })
- this.$emit('onSuccess')
- },
- setPickerOptions (val) {
- var startDate = val.deliverydate
- startDate = startDate.replace(new RegExp("-","gm"),"/")
- var startDateM = (new Date(startDate)).getTime()
- this.pickerOptions = {
- disabledDate(time) {
- return time.getTime() < startDateM;
- },
- }
- },
- async dateChange (row) {
- this.tableData = this.tableData.filter(e=>{
- if (e.delivery > 0) {
- e.deliverydate = this.value2
- }
- return e
- })
- const res = await this.$api.requested({
- "id": 20230104143102,
- "content": {
- "sa_orderid": this.$route.query.id,
- "deliverydate": this.value2
- },
- })
- },
- /*批量添加工具*/
- async addTools(data){
- let item = data.map(item => {
- return {
- sa_orderitemsid:0,
- itemid:item.itemid,
- qty:item.orderminqty,
- needdate:item.deliverydate
- }
- })
- let res = await this.$api.requested({
- "id": 20221109093602,
- "content": {
- "sa_orderid": this.$route.query.id, //订单ID
- "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
- "type": "工具借用单", //订单类型
- "items": item
- },
- })
- this.tool.showMessage(res,() => {
- this.listData()
- this.$refs.addTool.listData()
- this.$emit('onSuccess')
- })
- },
- /*单独添加*/
- async addTool(data){
- let res = await this.$api.requested({
- "id": 20221109093602,
- "content": {
- "sa_orderid": this.$route.query.id, //订单ID
- "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
- "type": "工具借用单", //订单类型
- "items": [
- {
- sa_orderitemsid:0,
- itemid:data.itemid,
- qty:data.orderminqty,
- needdate:data.deliverydate
- }
- ]
- },
- })
- this.tool.showMessage(res,() => {
- this.listData()
- this.$refs.addTool.listData()
- this.$emit('onSuccess')
- })
- },
- /*一键添加*/
- uploadData (uploadApi,data) {
- uploadApi.id = 20221109093602
- uploadApi.content = {
- "sa_orderid": this.$route.query.id, //订单ID
- "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
- "type": "工具借用单", //订单类型
- "items": data.map(e=>{
- return {
- sa_orderitemsid:0,
- itemid:e.itemid,
- qty:e.orderminqty,
- needdate:e.deliverydate
- }
- })
- }
- this.listData()
- this.$refs.addTool.listData()
- this.$emit('onSuccess')
- },
- /*拉取数据*/
- handlePullApi (pullApi) {
- pullApi.content = JSON.parse(JSON.stringify(this.param.content))
- pullApi.id = 20230116104102
- pullApi.content.sa_orderid = this.$route.query.id
- },
- /*一键删除*/
- handleDelApi (delApi,data) {
- delApi.id = 20221109093702
- delApi.content = {
- "sa_orderid":this.$route.query.id,
- "sa_orderitemsids": data,
- "pageNumber":0,
- "pageSize":0
- }
- this.listData()
- },
- },
- mounted () {
- this.listData()
- this.columnTitle = []
- this.$refs.multipleTable.$children.forEach(obj => {
- let columnChild = {'columnname':obj.prop,'filter':0,'rowindex':'','sequence':'','title':obj.label,'width':obj.width}
- // 存到columnTitle数组中
- this.columnTitle.push(columnChild)
- })
- },
- created() {
- this.tablecolsAdd = this.tool.tabelCol(this.$route.name).addToolTable.tablecols
- }
- }
- </script>
- <style>
- </style>
|