index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <div>
  3. <detail-template :headData="mainAreaData" :title="'订单号:'+orderData.sonum" :tabs="['订单明细','订单进度','发货单','收支明细']" :delParam="{id:'20221108152102',content:{sa_orderids:[router.currentRoute.value.query.id]}}" :disable="utils.isDisabled(orderData.status,['提交','审核','关闭','预提交','确认'])" size="small" :hideBorder="false" ownertable="sa_order">
  4. <template #operation>
  5. <a-space>
  6. <edit v-if="utils.hasPermission('update')" :data="orderData" @onSuccess="mianData" :disabled="utils.isDisabled(orderData.status,['提交','审核','关闭'],specialOrder('编辑'))"></edit>
  7. <a-button v-if="orderData.type === '特殊订单' && utils.hasPermission('preSubmission')" type="primary" @click="preSubmission" :disabled="utils.isDisabled(orderData.status,['提交','审核','关闭','预提交','确认'])">预提交</a-button>
  8. <a-button v-if="utils.hasPermission('submit')" type="primary" @click="submitOrder" :disabled="utils.isDisabled(orderData.status,['提交','审核','关闭'],(specialOrder('提交')))">提交</a-button>
  9. <!-- <a-button type="primary" @click="backOrder" :disabled="utils.isDisabled(orderData.status,['新建','审核','关闭'],specialOrder('撤回'))">撤回</a-button> -->
  10. </a-space>
  11. </template>
  12. <template #tab0>
  13. <div class="flex">
  14. <a-space class="mt-10">
  15. <!-- 添加产品 -->
  16. <select-product v-if="utils.hasPermission('orderDetail')" :disabled="utils.isDisabled(orderData.status,['提交','审核','关闭'],specialOrder('编辑'))" :param="listParam" @onSelect="addProductToBody">
  17. <template #tb_cell="{data}">
  18. <div v-if="data.column.dataIndex === 'qty'">
  19. <a-input-number style="width:100%" id="inputNumber" v-model:value="data.record.qty" :min="data.record.orderminqty" :step="data.record.orderaddqty"/>
  20. </div>
  21. </template>
  22. </select-product>
  23. <a-button v-if="utils.hasPermission('orderDetail')" :disabled="utils.isDisabled(orderData.status,['提交','审核','关闭'],(selectProductList.length == 0 || specialOrder('编辑')))" type="primary" @click="deleteProd">删除产品</a-button>
  24. </a-space>
  25. </div>
  26. <product-list :loading="loading" ref="prodlist" :columns="columns" :param="param" size="small" @onSelect="onProdSelect">
  27. <template #operation>
  28. <a-input class="search-input" v-model:value="param.content.where.condition" @keyup.enter="onSearch" placeholder="搜索产品"></a-input>
  29. </template>
  30. <template #tb_cell="{data}">
  31. <template v-if="data.column.dataIndex === 'qty'">
  32. <a-input-number style="width:100%" id="inputNumber" :disabled="utils.isDisabled(orderData.status,['提交','审核','关闭'],specialOrder('编辑'))" v-model:value="data.record.qty" :min="data.record.orderminqty" :step="data.record.orderaddqty" @change="inputChange(data.record)"/>
  33. </template>
  34. <template v-if="data.column.dataIndex === 'remarks'">
  35. <a-input style="width:100%" :disabled="utils.isDisabled(orderData.status,['提交','审核','关闭'],specialOrder('编辑'))" v-model:value="data.record.remarks" :min="1" @change="inputChange(data.record)" placeholder="请输入产品备注"/>
  36. </template>
  37. <template v-if="data.column.dataIndex === 'defaultprice'">
  38. {{utils.formatAmount(data.record.defaultprice)}}
  39. </template>
  40. <template v-if="data.column.dataIndex === 'price'">
  41. {{utils.formatAmount(data.record.price)}}
  42. </template>
  43. <template v-if="data.column.dataIndex === 'amount'">
  44. {{utils.formatAmount(data.record.amount)}}
  45. </template>
  46. </template>
  47. </product-list>
  48. </template>
  49. <template #tab1>
  50. <od-progress></od-progress>
  51. </template>
  52. <template #tab2>
  53. <dispatch-temp></dispatch-temp>
  54. </template>
  55. <template #tab3>
  56. <income-mx></income-mx>
  57. </template>
  58. </detail-template>
  59. </div>
  60. </template>
  61. <script setup>
  62. import Api from '@/api/api'
  63. import productList from '@/template/billProductTable/index.vue'
  64. import SelectProduct from '@/template/selectProduct/index.vue'
  65. import detailTemplate from '@/components/detailTemplate/index.vue'
  66. import edit from './modules/edit.vue'
  67. import OdProgress from './tabs/progress.vue'
  68. import DispatchTemp from './tabs/dispatch.vue'
  69. import IncomeMx from './tabs/income.vue'
  70. import { Modal } from 'ant-design-vue'
  71. import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  72. import { useRouter } from "vue-router"
  73. import { onMounted,ref,getCurrentInstance,createVNode,computed} from "vue"
  74. import utils from '@/utils/utils'
  75. const router = useRouter()
  76. const mainAreaData = ref([])
  77. const param = ref({
  78. "id": 20221109093902,
  79. "content": {
  80. "sa_orderid": router.currentRoute.value.query.id, //订单ID
  81. "pageNumber": 1,
  82. "pageSize": 20,
  83. "where": {
  84. "condition": ""
  85. }
  86. },
  87. })
  88. const loading = ref(false)
  89. let time = ref(null)
  90. const prodlist = ref(null);
  91. const orderData = ref({})
  92. const selectProductList = ref([])
  93. const listParam = computed(()=>{
  94. let params = {id:0,content:{sa_orderid:orderData.sa_orderid,pageNumber:1,pageSize:20,where:{condition:''}}}
  95. switch (orderData.value.type) {
  96. case '标准订单':
  97. params.id = 20221109153502
  98. break;
  99. case '项目订单':
  100. params.id = 20230103155002
  101. break;
  102. case '促销订单':
  103. params.id = 20230107182302
  104. break;
  105. case '工具订单':
  106. params.id = 20221109153502
  107. break;
  108. default:
  109. params.id = 20221109153502
  110. break;
  111. }
  112. return params
  113. })
  114. const specialOrder = (btn)=>{
  115. if (orderData.value.type === '特殊订单') {
  116. if (orderData.value.status === '确认' && btn === '提交') {
  117. return false
  118. } else if (orderData.value.status === '预提交') {
  119. return true
  120. } else if (orderData.value.status === '新建' && btn === '编辑'){
  121. return false
  122. } else {
  123. return true
  124. }
  125. } else {
  126. return false
  127. }
  128. }
  129. const mianData = async ()=>{
  130. const res = await Api.requested({
  131. "id":'20221108151302',
  132. "content": {
  133. "nocache":true,
  134. "sa_orderid": router.currentRoute.value.query.id
  135. }
  136. })
  137. orderData.value = res.data
  138. changeDataStructure(res.data)
  139. }
  140. const changeDataStructure = (data) => {
  141. mainAreaData.value = [
  142. {
  143. label:'订单状态',
  144. value:data.status,
  145. style:function() {
  146. let style = {}
  147. switch (data.status) {
  148. case '新建':
  149. style = {color:"#000000"}
  150. break;
  151. case '提交':
  152. style = {color:"#d90a0a"}
  153. break;
  154. case '交期待确认':
  155. style = {color:"#e09a1a"}
  156. break;
  157. case '交期确认':
  158. style = {color:"#3874f6"}
  159. break;
  160. case '审核':
  161. style = {color:"#52C41A"}
  162. break;
  163. case '关闭':
  164. style = {color:"#b2c0ea"}
  165. break;
  166. default:
  167. break;
  168. }
  169. return style
  170. },
  171. },
  172. {
  173. label:'订单类型',
  174. value:data.type,
  175. },
  176. {
  177. label:'明细分类',
  178. value:data.typemx,
  179. },
  180. {
  181. label:'单据日期',
  182. value:data.billdate,
  183. },
  184. {
  185. label:'企业名称',
  186. value:data.enterprisename,
  187. },
  188. {
  189. label:'订单金额',
  190. value:utils.formatAmount(data.defaultamount),
  191. },
  192. {
  193. label:'折后金额',
  194. value:utils.formatAmount(data.amount),
  195. },
  196. {
  197. label:'合计数量',
  198. value:data.qty,
  199. },
  200. {
  201. label:'领域',
  202. value:data.tradefield,
  203. },
  204. {
  205. label:'业务员',
  206. value:data.saler_name,
  207. },
  208. {
  209. label:'开票单位',
  210. value:data.finance.enterprisename,
  211. },
  212. {
  213. label:'支付账户',
  214. value:data.accountclass.accountname,
  215. },
  216. {
  217. label:'账户余额',
  218. value:data.accountclass.balance
  219. },
  220. {
  221. label:'信用额度',
  222. value:data.accountclass.creditquota
  223. },
  224. {
  225. label:'退回原因',
  226. value:data.backreason,
  227. span:4
  228. },
  229. {
  230. label:'备注',
  231. value:data.remarks,
  232. span:6
  233. },
  234. ]
  235. }
  236. const updateProd = async (data,msg) =>{
  237. loading.value = true
  238. const res = await Api.requested({
  239. id:20221109093602,
  240. content:{
  241. sa_orderid:orderData.value.sa_orderid,
  242. sys_enterpriseid:orderData.value.sys_enterpriseid,
  243. type:orderData.value.type,
  244. items:data
  245. }
  246. })
  247. utils.message(res,msg,()=>{
  248. mianData()
  249. })
  250. prodlist.value.listData()
  251. loading.value = false
  252. }
  253. const addProductToBody = async (val) =>{
  254. let data = val.map(e=>{
  255. return {
  256. sa_orderitemsid:0,
  257. itemid:e.itemid,
  258. qty:e.qty
  259. }
  260. })
  261. updateProd(data,'添加成功',()=>{
  262. prodlist.value.tableRecord = []
  263. })
  264. }
  265. const inputChange = (val) =>{
  266. let data = [{
  267. sa_orderitemsid:val.sa_orderitemsid,
  268. itemid:val.itemid,
  269. qty:val.qty,
  270. remarks:val.remarks
  271. }]
  272. if(time !== null){
  273. clearTimeout(time);
  274. }
  275. time = setTimeout(() => {
  276. updateProd(data,'修改成功')
  277. },500)
  278. }
  279. const onProdSelect = (val) => {
  280. selectProductList.value = val
  281. }
  282. const deleteProd = ()=>{
  283. console.log(selectProductList.value)
  284. Modal.confirm({
  285. title: '删除产品',
  286. icon: createVNode(ExclamationCircleOutlined),
  287. content: `当前选中${selectProductList.value.length}个产品,删除${selectProductList.value.length}个产品!`,
  288. async onOk() {
  289. loading.value = true
  290. const res = await Api.requested({
  291. id:20221109093702,
  292. content:{
  293. sa_orderid:orderData.value.sa_orderid,
  294. sa_orderitemsids:selectProductList.value.map(e=>{
  295. return e.sa_orderitemsid
  296. })
  297. }
  298. })
  299. utils.message(res,'删除成功',()=>{
  300. loading.value = false
  301. prodlist.value.selectedRowKeys = []
  302. prodlist.value.tableRecord = []
  303. selectProductList.value = []
  304. prodlist.value.listData()
  305. mianData()
  306. })
  307. },
  308. onCancel() {},
  309. });
  310. }
  311. const submitOrder = ()=>{
  312. Modal.confirm({
  313. title: '提交订单',
  314. icon: createVNode(ExclamationCircleOutlined),
  315. content: `确认提交该订单吗!`,
  316. async onOk() {
  317. const res = await Api.requested({
  318. "id": 20221108153402,
  319. "content": {
  320. "sa_orderid": orderData.value.sa_orderid,
  321. "sys_enterpriseid": orderData.value.sys_enterpriseid,
  322. "sa_accountclassid": orderData.value.sa_accountclassid
  323. },
  324. })
  325. utils.message(res,'提交成功',()=>{
  326. mianData()
  327. })
  328. },
  329. onCancel() {},
  330. });
  331. }
  332. const backOrder = ()=>{
  333. Modal.confirm({
  334. title: '撤回订单',
  335. icon: createVNode(ExclamationCircleOutlined),
  336. content: `确认撤回该订单吗!`,
  337. async onOk() {
  338. const res = await Api.requested({
  339. "id": 20230301190202,
  340. "content": {
  341. "sa_orderid": orderData.value.sa_orderid,
  342. },
  343. })
  344. utils.message(res,'撤回成功',()=>{
  345. mianData()
  346. })
  347. },
  348. onCancel() {},
  349. });
  350. }
  351. const preSubmission = async ()=> {
  352. Modal.confirm({
  353. title: '预提交订单',
  354. icon: createVNode(ExclamationCircleOutlined),
  355. content: `确认预提交该订单吗!`,
  356. async onOk() {
  357. const res = await Api.requested({
  358. "id": 20230331152503,
  359. "content": {
  360. "sa_orderid": orderData.value.sa_orderid,
  361. "isrecheck":true
  362. },
  363. })
  364. utils.message(res,'预提交成功',()=>{
  365. mianData()
  366. })
  367. },
  368. onCancel() {},
  369. });
  370. }
  371. const onSearch = ()=>{
  372. param.value.content.pageNumber = 1
  373. prodlist.value.listData()
  374. }
  375. const columns = [
  376. {
  377. title:'行号',
  378. dataIndex:'rowno',
  379. width:90,
  380. ellipsis:true,
  381. fixed:true
  382. },
  383. {
  384. title:'产品名称',
  385. dataIndex:'itemname',
  386. width:180,
  387. ellipsis:true,
  388. fixed:true
  389. },
  390. {
  391. title:'产品编号',
  392. dataIndex:'itemno',
  393. width:180,
  394. ellipsis:true,
  395. fixed:true
  396. },
  397. {
  398. title:'型号',
  399. dataIndex:'model',
  400. width:180,
  401. ellipsis:true,
  402. fixed:true
  403. },
  404. {
  405. title:'数量',
  406. dataIndex:'qty',
  407. width:120,
  408. ellipsis:true,
  409. },
  410. {
  411. title:'原价',
  412. dataIndex:'defaultprice',
  413. width:180,
  414. ellipsis:true,
  415. },
  416. {
  417. title:'单价',
  418. dataIndex:'price',
  419. width:180,
  420. ellipsis:true,
  421. },
  422. {
  423. title:'金额',
  424. dataIndex:'amount',
  425. width:180,
  426. ellipsis:true,
  427. },
  428. {
  429. title:'包装数量',
  430. dataIndex:'packageqty',
  431. width:180,
  432. ellipsis:true,
  433. },
  434. {
  435. title:'未发货数量',
  436. dataIndex:'undeliqty',
  437. width:180,
  438. ellipsis:true,
  439. },
  440. {
  441. title:'备注',
  442. dataIndex:'remarks',
  443. width:360,
  444. ellipsis:true,
  445. }
  446. ]
  447. onMounted (()=>{
  448. mianData()
  449. })
  450. </script>
  451. <style scoped>
  452. .flex{
  453. display: flex;
  454. }
  455. .search-input{
  456. width: 300px;
  457. margin-bottom: 20px;
  458. }
  459. </style>