index.vue 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260
  1. <template>
  2. <div class="my-container">
  3. <div class="bill-left" v-show="isShow==='home'" key="item">
  4. <div class="bill-tab">
  5. <div class="bill-title">导航</div>
  6. <side-tree :propConfig="treeConfig" @onChange="onChangeTree" ref="sideTree" />
  7. </div>
  8. </div>
  9. <div class="bill-main" v-show="isShow==='home'" key="item2">
  10. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
  11. @resert="onRefresh" @clickHandle="clickHandle" @detail="getDetail" @onRefresh="onRefresh" />
  12. </div>
  13. <!-- 新增/编辑 -->
  14. <div class="detil" v-show="isShow==='add'" key="item3">
  15. <by-tool :propConfig="toolConfig" @clickHandle="insideTools" ref="byTool" />
  16. <div class="box-shadow">
  17. <el-button style="margin-bottom: 20px;" type="primary" icon="el-icon-sort" @click="openVxeData">关联金蝶财务系统物料</el-button>
  18. <by-form :propConfig="formConfig" ref="form">
  19. <template v-slot:description>
  20. <el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="textarea">
  21. </el-input>
  22. </template>
  23. <template v-slot:tags>
  24. <el-tag style="margin-right: 16px;" :disable-transitions="true" v-for="(item,index) of tagsData"
  25. :key="index" closable @close="handleClose2(index)">
  26. {{item}}
  27. </el-tag>
  28. <by-input class="input-new-tag" ref="tagsValue" style="width: 150px;"></by-input>
  29. <el-button class="button-new-tag" @click="getTagsValue">添加</el-button>
  30. </template>
  31. <template v-slot:status>
  32. <el-radio v-model="status" :label="0">启用</el-radio>
  33. <el-radio v-model="status" :label="1">备用</el-radio>
  34. <el-radio v-model="status" :label="2">禁用</el-radio>
  35. </template>
  36. <template v-slot:ismakeup>
  37. <el-radio v-model="ismakeup" :label="0" :disabled="materialSpec==1">是</el-radio>
  38. <el-radio v-model="ismakeup" :label="1">否</el-radio>
  39. <el-button v-show="ismakeup===0" @click="openMakeup">选择商品</el-button>
  40. </template>
  41. <template v-slot:makeupTable>
  42. <div v-if="ismakeup===0">
  43. <by-table :propConfig="makeupTable" ref="makeupTable" @onChangeRow="getMakeupTableValue"></by-table>
  44. </div>
  45. </template>
  46. <template v-slot:issued>
  47. <el-radio v-model="issued" :label="0">是</el-radio>
  48. <el-radio v-model="issued" :label="1">否</el-radio>
  49. </template>
  50. <template v-slot:materialSpec>
  51. <el-radio v-model="materialSpec" :label="0" @input="changeSingle">单规格</el-radio>
  52. <el-radio v-model="materialSpec" :label="1" @input="changeSingle" :disabled="ismakeup==0">多规格</el-radio>
  53. </template>
  54. <template v-slot:attributeName>
  55. <div v-if="isSingle" key="item4">
  56. <by-table :propConfig="singleTable" @onChangeRow="getInputValue" ref="singeTable">
  57. <template v-slot:stock="{row}">
  58. <vxe-input v-if="!isEdit" v-model="row.stock" size="mini" type="integer"></vxe-input>
  59. <span v-else>{{ row.stock }}</span>
  60. </template>
  61. </by-table>
  62. </div>
  63. <div v-if="!isSingle" key="item5">
  64. <el-select :value="selectValue" clearable placeholder="请选择" style="width: 19.5%;" @input="getSelectValue">
  65. <el-option v-for="item in selectList" :key="item.value" :label="item.name" :value="item.id">
  66. </el-option>
  67. </el-select>
  68. <div class="by-tab" key="item6">
  69. <div v-for="(item,index) of attributeList" :key="index">
  70. <div class="tab-title">{{item.title}} <i class="el-icon-circle-close" @click="closeGroup(index)"></i>
  71. </div>
  72. <el-tag class="item-tab" :disable-transitions="true" :key="i" v-for="(tag,i) of item.list" closable
  73. @close="handleClose(tag,index)">
  74. {{tag}}
  75. </el-tag>
  76. <by-input class="input-new-tag" :ref="'getValue_'+index"></by-input>
  77. <el-button class="button-new-tag" @click="showInput(index)">添加</el-button>
  78. </div>
  79. <div style="margin: 20px 0;" v-if="!isAdd" key="item7">
  80. <div class="el-button mr15 el-button--primary el-button--small" @click="isAdd=true">添加新规格</div>
  81. </div>
  82. <div style="display: flex;margin: 20px 0;" v-else key='item8'>
  83. <div class="flex-item">
  84. <label>规格:</label>
  85. <div class="el-input el-input--small" style="width: 250px;margin-right: 16px;">
  86. <input type="text" v-model="norms" placeholder="请输入规格" class="el-input__inner">
  87. </div>
  88. </div>
  89. <div class="flex-item">
  90. <label>规格值:</label>
  91. <div class="el-input el-input--small" style="width: 250px;margin-right: 16px;">
  92. <input type="text" v-model="normsValue" placeholder="请输入规格值" class="el-input__inner">
  93. </div>
  94. </div>
  95. <div @click="doComfirm" class="el-button el-button--primary el-button--small">确定</div>
  96. <div @click="isAdd=false" class="el-button el-button--danger el-button--small">取消</div>
  97. </div>
  98. <div>
  99. <by-table :propConfig="tableConfig" @onChangeRow="getInputValue" ref="table">
  100. <template v-slot:stock="{row}">
  101. <vxe-input v-if="!isEdit" v-model="row.stock" size="mini" type="integer"></vxe-input>
  102. <span v-else>{{ row.stock }}</span>
  103. </template>
  104. </by-table>
  105. </div>
  106. </div>
  107. </div>
  108. </template>
  109. </by-form>
  110. </div>
  111. </div>
  112. <!-- 选择物料 -->
  113. <productModal ref="product" :mulit="true" @confirm="confirmProduct" />
  114. <vxe-modal v-model="vxeValue" width="48%" height="88%" show-zoom resize transfer show-footer mask-closable :loading="tableloading">
  115. <template #title>
  116. <span>关联金蝶财务系统物料</span>
  117. </template>
  118. <template #default>
  119. <el-form ref="tableSearchForm" :inline="true" :model="tableSearchForm" label-width="80px">
  120. <el-form-item label="标题">
  121. <el-input style="width: 220px;" v-model="tableSearchForm.fname" placeholder="请输入标题" clearable></el-input>
  122. </el-form-item>
  123. <el-form-item label="财务编号">
  124. <el-input style="width: 220px;" v-model="tableSearchForm.fnumber" placeholder="请输入财务编号" clearable></el-input>
  125. </el-form-item>
  126. <el-form-item label="开始时间">
  127. <el-date-picker style="width: 220px;" v-model="tableSearchForm.stime" type="date" placeholder="选择日期" :clearable="false" value-format="yyyy-MM-dd"></el-date-picker>
  128. </el-form-item>
  129. <el-form-item label="结束时间">
  130. <el-date-picker style="width: 220px;" v-model="tableSearchForm.etime" type="date" placeholder="选择日期" :clearable="false" value-format="yyyy-MM-dd"></el-date-picker>
  131. </el-form-item>
  132. <el-form-item>
  133. <el-button type="primary" @click="tableSearchOnSubmit">搜索</el-button>
  134. <el-button @click="resetTableSearch">重置</el-button>
  135. </el-form-item>
  136. </el-form>
  137. <el-table
  138. ref="multipleTable"
  139. :data="newtableData"
  140. stripe
  141. border
  142. style="width: 100%"
  143. :header-cell-style="{ background: '#f3f6fd', color: '#555'}">
  144. <el-table-column
  145. width="55">
  146. <template slot-scope="scope">
  147. <el-radio v-model="tableRadio" :label="scope.row" @input="handleSelectionChange">{{""}}</el-radio>
  148. </template>
  149. </el-table-column>
  150. <el-table-column prop="fname" label="标题"></el-table-column>
  151. <el-table-column prop="fnumber" label="财务编号"></el-table-column>
  152. <el-table-column prop="fbaseUnitName" label="单位"></el-table-column>
  153. <el-table-column prop="fbaseUnitCode" label="单位编码"></el-table-column>
  154. </el-table>
  155. <el-pagination
  156. style="margin-top: 25px;"
  157. background
  158. layout="prev, pager, next"
  159. :page-size="tablePageSize"
  160. :current-page="tablePageNum"
  161. :total="tableDataTotal"
  162. @current-change="currentChange">
  163. </el-pagination>
  164. </template>
  165. <template #footer>
  166. <div class="btn">
  167. <el-button size="small" @click="vxeValue=false">取消</el-button>
  168. <el-button type="primary" size="small" @click="doConfirm">确定</el-button>
  169. </div>
  170. </template>
  171. </vxe-modal>
  172. <el-dialog
  173. title="同步金蝶物料"
  174. v-loading="dateLoading"
  175. :visible.sync="dateDialogVisible"
  176. :close-on-click-modal='false'
  177. :close-on-press-escape='false'
  178. :show-close='false'
  179. width="518px">
  180. <el-date-picker v-model="stime" type="date" :picker-options="stimePickerOptions" placeholder="选择日期" value-format="yyyy-MM-dd"></el-date-picker>
  181. <span style="margin: 0 12px;">至</span>
  182. <el-date-picker v-model="etime" type="date" :picker-options="etimePickerOptions" placeholder="选择日期" value-format="yyyy-MM-dd"></el-date-picker>
  183. <span slot="footer" class="dialog-footer">
  184. <el-button @click="dateDialogVisible = false">取 消</el-button>
  185. <el-button type="primary" @click="dateConfirm">确 定</el-button>
  186. </span>
  187. </el-dialog>
  188. </div>
  189. </template>
  190. <script lang="ts">
  191. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  192. import api from '@/api/currency'
  193. import other from '@/api/other'
  194. import ForTab from "@/components/ForTab/index.vue";
  195. import productModal from "./components/productModal.vue";
  196. import brandType from "./components/brandType.vue";
  197. // import selectKin from "./components/selectKin.vue";
  198. @Component({ components: { ForTab, productModal, brandType } })
  199. export default class productManagement extends Vue {
  200. tagsData : any = [] // 标签值
  201. isShow = 'home'
  202. isEdit = true
  203. vxeValue = false
  204. editInfo : any = ''
  205. isSingle : any = true
  206. timeNum = 0;
  207. timer : any = null
  208. materialSpec : any = 0
  209. status : any = 0
  210. ismakeup : any = 1
  211. issued : any = 0
  212. textarea : any = ''
  213. categoryIds : any = ''
  214. selectList = []
  215. selectValue = ''
  216. // tab
  217. singeTable : any = ''
  218. setTableConfig : any = ''
  219. towTable : any = ''
  220. attributeList : any = [] // 物料属性规格
  221. inputValue : any = ''
  222. norms : any = ''
  223. normsValue : any = ''
  224. isAdd : any = false
  225. skuRuleList : any = ''
  226. tableList : any = ''
  227. attributeId : any = ''
  228. intercept : any = ''
  229. makeupList : any = [] // 组合商品列表
  230. dateDialogVisible = false
  231. dateLoading = false
  232. stime : any = null
  233. etime : any = null
  234. stimePickerOptions : any = {
  235. disabledDate(time : any) {
  236. return time.getTime() > Date.now();
  237. }
  238. }
  239. etimePickerOptions : any = {
  240. disabledDate(time : any) {
  241. return time.getTime() > Date.now();
  242. }
  243. }
  244. // tab
  245. toolConfig = {
  246. tools: {
  247. return: true,
  248. save: true,
  249. }
  250. }
  251. treeConfig = {
  252. attr: {
  253. retConfig: {
  254. id: 'id',
  255. },
  256. defaultExpandAll: true,
  257. label: 'name',
  258. // resType: 'data'
  259. },
  260. // request: {
  261. // url: '/maindata/maindataMaterialCategory/treeUseList',
  262. // method: 'GET'
  263. // }
  264. }
  265. singleTable : any = {
  266. attr: {
  267. size: 'mini',
  268. align: 'left',
  269. editRules: {
  270. skuTitle: [
  271. { required: true, message: '请输入标题'}
  272. ],
  273. skuCode: [
  274. { required: true, message: '请输入物料编码'}
  275. ],
  276. barCode: [
  277. { required: true, message: '请输入69码-商品条码'}
  278. ]
  279. }
  280. },
  281. columns: [
  282. {
  283. // width: '150px',
  284. title: '标题(必填项)',
  285. field: 'skuTitle',
  286. component: 'by-input',
  287. compConfig: {
  288. attr: {
  289. size: 'mini',
  290. placeholder: ' '
  291. },
  292. }
  293. },
  294. {
  295. // width: '150px',
  296. title: '副标题',
  297. field: 'skuSubtitle',
  298. component: 'by-input',
  299. compConfig: {
  300. attr: {
  301. size: 'mini',
  302. placeholder: ' '
  303. },
  304. }
  305. },
  306. {
  307. // width: '150px',
  308. title: '物料编码(必填项)',
  309. field: 'skuCode',
  310. component: 'by-input',
  311. compConfig: {
  312. attr: {
  313. size: 'mini',
  314. placeholder: ' '
  315. },
  316. }
  317. },
  318. {
  319. width: '110px',
  320. title: '69码-商品条码(必填项)',
  321. field: 'barCode',
  322. component: 'by-input',
  323. // width:110,
  324. compConfig: {
  325. attr: {
  326. size: 'mini',
  327. placeholder: ' '
  328. },
  329. }
  330. },
  331. // {
  332. // width: '55px',
  333. // component: selectKin
  334. // },
  335. {
  336. // width: '150px',
  337. title: '财务编号',
  338. field: 'financialCode',
  339. component: 'by-input',
  340. compConfig: {
  341. attr: {
  342. size: 'mini',
  343. placeholder: ' '
  344. },
  345. }
  346. },
  347. {
  348. width: '90px',
  349. title: '价格',
  350. field: 'price',
  351. component: 'by-input',
  352. compConfig: {
  353. attr: {
  354. size: 'mini',
  355. placeholder: ' ',
  356. type: "number",
  357. min: 0,
  358. defaultValue: 0
  359. },
  360. }
  361. },
  362. {
  363. width: '90px',
  364. title: '单位',
  365. field: 'unit',
  366. component: 'by-input',
  367. compConfig: {
  368. attr: {
  369. size: 'mini',
  370. placeholder: ' ',
  371. },
  372. }
  373. },
  374. {
  375. width: '90px',
  376. title: '单位编码',
  377. field: 'unitCode',
  378. component: 'by-input',
  379. compConfig: {
  380. attr: {
  381. size: 'mini',
  382. placeholder: ' ',
  383. },
  384. }
  385. },
  386. // {
  387. // width: '70px',
  388. // title: '库存',
  389. // field: 'stock',
  390. // slot: true,
  391. // },
  392. {
  393. width: '100px',
  394. title: '保质期(天)',
  395. field: 'shelfLife',
  396. component: 'by-input',
  397. compConfig: {
  398. attr: {
  399. size: 'mini',
  400. placeholder: ' ',
  401. type: "integer",
  402. min: 0,
  403. },
  404. }
  405. },
  406. {
  407. width: '80px',
  408. title: '重量/g',
  409. field: 'weight',
  410. component: 'by-input',
  411. compConfig: {
  412. attr: {
  413. size: 'mini',
  414. placeholder: ' ',
  415. type: "number",
  416. min: 0,
  417. },
  418. }
  419. },
  420. {
  421. width: '80px',
  422. title: '长/cm',
  423. field: 'length',
  424. component: 'by-input',
  425. compConfig: {
  426. attr: {
  427. size: 'mini',
  428. placeholder: ' ',
  429. type: "number",
  430. min: 0,
  431. },
  432. }
  433. },
  434. {
  435. width: '80px',
  436. title: '宽/cm',
  437. field: 'width',
  438. component: 'by-input',
  439. compConfig: {
  440. attr: {
  441. size: 'mini',
  442. placeholder: ' ',
  443. type: "number",
  444. min: 0,
  445. },
  446. }
  447. },
  448. {
  449. width: '80px',
  450. title: '高/cm',
  451. field: 'height',
  452. component: 'by-input',
  453. compConfig: {
  454. attr: {
  455. size: 'mini',
  456. placeholder: ' ',
  457. type: "number",
  458. min: 0,
  459. },
  460. }
  461. },
  462. {
  463. width: '80px',
  464. title: '体积/cm³',
  465. field: 'volume',
  466. },
  467. // {
  468. // width: '100px',
  469. // title: '操作',
  470. // action: true,
  471. // // plugins: [{
  472. // // icon: 'el-icon-edit',
  473. // // name: '选择物料',
  474. // // audit: '',
  475. // // event: {
  476. // // click: () => {
  477. // // (this as any).openVxeData(1)
  478. // // }
  479. // // }
  480. // // }]
  481. // }
  482. ]
  483. }
  484. tableConfig : any = {
  485. attr: {
  486. size: 'mini',
  487. align: 'left',
  488. editRules: {
  489. skuTitle: [
  490. { required: true, message: '请输入标题'}
  491. ],
  492. skuCode: [
  493. { required: true, message: '请输入物料编码'}
  494. ],
  495. barCode: [
  496. { required: true, message: '请输入69码-商品条码'}
  497. ]
  498. }
  499. },
  500. columns: [
  501. {
  502. width: '160px',
  503. title: '标题(必填项)',
  504. field: 'skuTitle',
  505. component: 'by-input',
  506. compConfig: {
  507. attr: {
  508. size: 'mini',
  509. placeholder: ' '
  510. },
  511. }
  512. },
  513. {
  514. width: '120px',
  515. title: '副标题',
  516. field: 'skuSubtitle',
  517. component: 'by-input',
  518. compConfig: {
  519. attr: {
  520. size: 'mini',
  521. placeholder: ' '
  522. },
  523. }
  524. },
  525. {
  526. width: '140px',
  527. title: '物料编码(必填项)',
  528. field: 'skuCode',
  529. component: 'by-input',
  530. compConfig: {
  531. attr: {
  532. size: 'mini',
  533. placeholder: ' '
  534. },
  535. }
  536. },
  537. {
  538. width: '110px',
  539. title: '69码-商品条码(必填项)',
  540. field: 'barCode',
  541. component: 'by-input',
  542. compConfig: {
  543. attr: {
  544. size: 'mini',
  545. placeholder: ' ',
  546. },
  547. }
  548. },
  549. // {
  550. // width: '55px',
  551. // component: selectKin
  552. // },
  553. {
  554. width: '140px',
  555. title: '财务编号',
  556. field: 'financialCode',
  557. component: 'by-input',
  558. compConfig: {
  559. attr: {
  560. size: 'mini',
  561. placeholder: ' '
  562. },
  563. }
  564. },
  565. {
  566. width: '80px',
  567. title: '价格',
  568. field: 'price',
  569. component: 'by-input',
  570. compConfig: {
  571. attr: {
  572. size: 'mini',
  573. placeholder: ' ',
  574. type: "number",
  575. min: 0,
  576. },
  577. }
  578. },
  579. {
  580. width: '80px',
  581. title: '单位',
  582. field: 'unit',
  583. component: 'by-input',
  584. compConfig: {
  585. attr: {
  586. size: 'mini',
  587. placeholder: ' ',
  588. },
  589. }
  590. },
  591. {
  592. width: '80px',
  593. title: '单位编码',
  594. field: 'unitCode',
  595. component: 'by-input',
  596. compConfig: {
  597. attr: {
  598. size: 'mini',
  599. placeholder: ' ',
  600. },
  601. }
  602. },
  603. // {
  604. // width: '80px',
  605. // title: '库存',
  606. // field: 'stock',
  607. // slot: true,
  608. // },
  609. {
  610. width: '100px',
  611. title: '保质期(天)',
  612. field: 'shelfLife',
  613. component: 'by-input',
  614. compConfig: {
  615. attr: {
  616. size: 'mini',
  617. placeholder: ' ',
  618. type: "integer",
  619. min: 0,
  620. },
  621. }
  622. },
  623. {
  624. width: '80px',
  625. title: '重量/g',
  626. field: 'weight',
  627. component: 'by-input',
  628. compConfig: {
  629. attr: {
  630. size: 'mini',
  631. placeholder: ' ',
  632. type: "number",
  633. min: 0,
  634. },
  635. }
  636. },
  637. {
  638. width: '80px',
  639. title: '长/cm',
  640. field: 'length',
  641. component: 'by-input',
  642. compConfig: {
  643. attr: {
  644. size: 'mini',
  645. placeholder: ' ',
  646. type: "number",
  647. min: 0,
  648. },
  649. }
  650. },
  651. {
  652. width: '80px',
  653. title: '宽/cm',
  654. field: 'width',
  655. component: 'by-input',
  656. compConfig: {
  657. attr: {
  658. size: 'mini',
  659. placeholder: ' ',
  660. type: "number",
  661. min: 0,
  662. },
  663. }
  664. },
  665. {
  666. width: '80px',
  667. title: '高/cm',
  668. field: 'height',
  669. component: 'by-input',
  670. compConfig: {
  671. attr: {
  672. size: 'mini',
  673. placeholder: ' ',
  674. type: "number",
  675. min: 0,
  676. },
  677. }
  678. },
  679. {
  680. width: '80px',
  681. title: '体积/cm³',
  682. field: 'volume',
  683. },
  684. {
  685. width: '180px',
  686. title: '操作',
  687. action: true,
  688. plugins: [
  689. // {
  690. // icon: 'el-icon-edit',
  691. // name: '选择物料',
  692. // audit: '',
  693. // event: {
  694. // click: () => {
  695. // (this as any).openVxeData(2)
  696. // }
  697. // }
  698. // },
  699. {
  700. icon: 'el-icon-delete',
  701. name: '删除',
  702. audit: '',
  703. event: {
  704. click: (item : any) => {
  705. (this as any).doDeleteTable(item)
  706. }
  707. }
  708. },
  709. ]
  710. }
  711. ]
  712. }
  713. makeupTable : any = {
  714. attr: {
  715. size: 'mini',
  716. align: 'center',
  717. },
  718. columns: [
  719. {
  720. // width: '170px',
  721. title: '标题',
  722. field: 'title',
  723. },
  724. {
  725. // width: '170px',
  726. title: '副标题',
  727. field: 'subtitle',
  728. },
  729. {
  730. width: '170px',
  731. title: '数量',
  732. field: 'number',
  733. component: 'by-input',
  734. compConfig: {
  735. attr: {
  736. size: 'mini',
  737. defaultValue: '1',
  738. type: 'number',
  739. min: '0'
  740. },
  741. }
  742. },
  743. {
  744. width: 120,
  745. title: '操作',
  746. action: true,
  747. plugins: [{
  748. name: '删除',
  749. event: {
  750. click: (item : any) => (this as any).deleteMakeup(item)
  751. }
  752. }]
  753. }
  754. ]
  755. }
  756. formConfig = {
  757. attr: {
  758. size: 'medium',
  759. rules: {
  760. name: [{
  761. required: true, message: '请输入名称', trigger: 'blur'
  762. }],
  763. // materialCode: [{
  764. // required: true, message: '请输入物料编码', trigger: 'blur'
  765. // }],
  766. basePrice: [{
  767. required: true, message: '请输入基本售价', trigger: 'blur'
  768. }],
  769. categoryName: [{
  770. required: true, message: '请选择物料分类', trigger: 'change'
  771. }],
  772. brandId: [{
  773. required: true, message: '请选择物料品牌', trigger: 'change'
  774. }],
  775. }
  776. },
  777. columns: [
  778. [
  779. {
  780. span: 6,
  781. label: '名称',
  782. prop: 'name',
  783. component: 'by-input',
  784. compConfig: {
  785. attr: {
  786. placeholder: '请输入名称',
  787. clearable: true
  788. }
  789. }
  790. },
  791. {
  792. span: 6,
  793. label: '简称',
  794. prop: 'shortName',
  795. component: 'by-input',
  796. compConfig: {
  797. attr: {
  798. placeholder: '请输入简称',
  799. clearable: true
  800. }
  801. }
  802. },
  803. {
  804. span: 6,
  805. label: '物料编码',
  806. prop: 'materialCode',
  807. component: 'by-input',
  808. compConfig: {
  809. attr: {
  810. placeholder: '请输入物料编码',
  811. }
  812. }
  813. },
  814. {
  815. span: 6,
  816. label: '货号',
  817. prop: 'itemNumber',
  818. component: 'by-input',
  819. compConfig: {
  820. attr: {
  821. placeholder: '请输入货号',
  822. clearable: true
  823. }
  824. }
  825. },
  826. ],
  827. [
  828. {
  829. span: 6,
  830. label: '基本售价',
  831. prop: 'basePrice',
  832. component: 'by-input',
  833. compConfig: {
  834. attr: {
  835. placeholder: '请输入基本售价',
  836. type: 'number',
  837. min: '0'
  838. }
  839. }
  840. },
  841. {
  842. span: 6,
  843. label: '市场价格',
  844. prop: 'markPrice',
  845. component: 'by-input',
  846. compConfig: {
  847. attr: {
  848. placeholder: '请输入市场价格',
  849. type: 'number',
  850. min: '0'
  851. }
  852. }
  853. },
  854. {
  855. span: 6,
  856. label: '国际码',
  857. prop: 'nsCode',
  858. component: 'by-input',
  859. compConfig: {
  860. attr: {
  861. placeholder: '请输入国际码',
  862. clearable: true
  863. }
  864. }
  865. },
  866. ],
  867. [
  868. {
  869. span: 6,
  870. label: '物料分类',
  871. prop: 'categoryName',
  872. component: 'select-tree',
  873. compConfig: {
  874. attr: {
  875. label: 'name',
  876. clearable: true,
  877. placeholder: '请选择物料分类',
  878. retConfig: {
  879. categoryName: 'name',
  880. categoryId: 'id'
  881. },
  882. defaultExpandAll: true
  883. },
  884. request: {
  885. url: '/maindata/maindataMaterialCategory/treeUseList'
  886. }
  887. }
  888. },
  889. {
  890. span: 6,
  891. label: '物料品牌',
  892. prop: 'brandId',
  893. component: brandType,
  894. },
  895. {
  896. span: 6,
  897. label: '虚拟分类',
  898. prop: 'vmCategoryName',
  899. component: 'select-tree',
  900. compConfig: {
  901. attr: {
  902. label: 'name',
  903. clearable: true,
  904. placeholder: '请选择虚拟分类',
  905. retConfig: {
  906. vmCategoryName: 'name',
  907. vmCategoryId: 'id'
  908. },
  909. defaultExpandAll: true
  910. },
  911. request: {
  912. url: '/maindata/maindataMaterialVmcategory/treeUseList'
  913. }
  914. }
  915. },
  916. {
  917. labelWidth: '116px',
  918. span: 6,
  919. label: '机构商品分类',
  920. prop: 'organizationCategoryName',
  921. component: 'select-tree',
  922. compConfig: {
  923. attr: {
  924. label: 'name',
  925. clearable: true,
  926. placeholder: '请选择机构商品分类',
  927. retConfig: {
  928. organizationCategoryName: 'name',
  929. organizationCategoryId: 'id'
  930. },
  931. defaultExpandAll: true
  932. },
  933. request: {
  934. url: '/maindata/maindataMaterialOrganizationCategory/treeUseList'
  935. }
  936. }
  937. },
  938. ],
  939. [
  940. {
  941. span: 30,
  942. label: '描述',
  943. slot: true,
  944. prop: 'description',
  945. }
  946. ],
  947. [
  948. {
  949. span: 20,
  950. label: '标签',
  951. slot: true,
  952. prop: 'tags',
  953. }
  954. ],
  955. [
  956. {
  957. span: 20,
  958. label: '物料状态',
  959. slot: true,
  960. prop: 'status',
  961. }
  962. ],
  963. [
  964. {
  965. span: 20,
  966. label: '组合商品',
  967. slot: true,
  968. prop: 'ismakeup',
  969. }
  970. ],
  971. [
  972. {
  973. span: 30,
  974. label: '',
  975. slot: true,
  976. prop: 'makeupTable',
  977. }
  978. ],
  979. [
  980. {
  981. span: 20,
  982. label: '是否公布',
  983. slot: true,
  984. prop: 'issued',
  985. }
  986. ],
  987. [
  988. {
  989. span: 20,
  990. label: '商品规格',
  991. slot: true,
  992. prop: 'materialSpec',
  993. }
  994. ],
  995. [
  996. {
  997. span: 30,
  998. label: '物料属性',
  999. slot: true,
  1000. prop: 'attributeName',
  1001. }
  1002. ],
  1003. ],
  1004. }
  1005. config : any = {
  1006. attr: {
  1007. calculateH: true
  1008. },
  1009. search: {
  1010. attr: {
  1011. size: 'mini'
  1012. },
  1013. columns: [
  1014. [
  1015. {
  1016. span: 6,
  1017. label: '名称',
  1018. prop: 'name',
  1019. component: 'by-input',
  1020. labelWidth: '70px',
  1021. compConfig: {
  1022. attr: {
  1023. placeholder: '请输入名称',
  1024. clearable: true
  1025. }
  1026. },
  1027. }, {
  1028. span: 6,
  1029. label: '简称',
  1030. prop: 'shortName',
  1031. component: 'by-input',
  1032. labelWidth: '70px',
  1033. compConfig: {
  1034. attr: {
  1035. placeholder: '请输入简称',
  1036. clearable: true
  1037. }
  1038. }
  1039. },
  1040. {
  1041. span: 6,
  1042. label: '货号',
  1043. prop: 'itemNumber',
  1044. component: 'by-input',
  1045. labelWidth: '70px',
  1046. compConfig: {
  1047. attr: {
  1048. placeholder: '请输入货号',
  1049. clearable: true
  1050. }
  1051. }
  1052. },
  1053. ],
  1054. ]
  1055. },
  1056. tool: {
  1057. tools: {
  1058. add: true,
  1059. delete: true,
  1060. search: true,
  1061. refresh: true,
  1062. },
  1063. customTools: [
  1064. {
  1065. name: '同步金蝶物料', icon: 'el-icon-top', audit: [''], event: {
  1066. click: () => {
  1067. (this as any).syncSystem()
  1068. }
  1069. }
  1070. },
  1071. ]
  1072. },
  1073. table: {
  1074. attr: {
  1075. size: 'mini',
  1076. align: 'left',
  1077. checkbox: true,
  1078. },
  1079. columns: [{
  1080. width: 250,
  1081. title: '名称',
  1082. field: 'name',
  1083. isDetail: true,
  1084. }, {
  1085. width: 200,
  1086. title: '简称',
  1087. field: 'shortName'
  1088. }, {
  1089. width: 200,
  1090. title: '货号',
  1091. field: 'itemNumber'
  1092. }, {
  1093. width: 200,
  1094. title: '国际码',
  1095. field: 'nsCode'
  1096. }, {
  1097. width: 90,
  1098. title: '基本售价',
  1099. field: 'basePrice'
  1100. }, {
  1101. width: 90,
  1102. title: '市场价格', // (市场价格统一售价)
  1103. field: 'markPrice'
  1104. },
  1105. {
  1106. width: 120,
  1107. title: '操作',
  1108. action: true,
  1109. plugins: [{
  1110. icon: 'el-icon-edit',
  1111. name: '编辑',
  1112. audit: '',
  1113. event: {
  1114. click: (item : any) => {
  1115. (this as any).getDetail(item)
  1116. }
  1117. }
  1118. }, {
  1119. name: '删除',
  1120. event: {
  1121. click: (item : any) => (this as any).doDelete2(item)
  1122. }
  1123. }]
  1124. }]
  1125. },
  1126. }
  1127. tableloading: boolean = true
  1128. tableRadio: any = {}
  1129. tableData: any = []
  1130. newtableData: any = []
  1131. tableSearchForm: any = {}
  1132. tableDataTotal: any = 0
  1133. tablePageSize: any = 10
  1134. tablePageNum: any = 1
  1135. productDataList: any = []
  1136. mounted() {
  1137. this.getAttribute()
  1138. this.timer = setInterval(() => {
  1139. this.getDataList()
  1140. }, 500)
  1141. // 获取关联金蝶财务系统物料列表
  1142. var t = new Date();
  1143. var y = t.getFullYear();
  1144. var m:any = t.getMonth()+1;
  1145. if(m<10){m='0'+m}
  1146. var d:any = t.getDate()
  1147. if(d<10){d='0'+d}
  1148. this.tableSearchForm.stime = '2020-01-01';
  1149. this.tableSearchForm.etime = y+'-'+m+'-'+d;
  1150. this.etime = y+'-'+m+'-'+d;
  1151. // this.getFinancialCode()
  1152. }
  1153. // 确定商品新增
  1154. confirmProduct(e : any) {
  1155. this.$nextTick(() => {
  1156. let nowData = (this.$refs.makeupTable as any).getValue();
  1157. let names = '';
  1158. if (e.length > 0) {
  1159. for (const item of e) {
  1160. this.productDataList.push(item)
  1161. let t = true;
  1162. for (const t_item of nowData) {
  1163. if (item.id == t_item.materialSkuId) {
  1164. if (!names) {
  1165. names = item.skuTitle
  1166. } else {
  1167. names = names + ',' + item.skuTitle
  1168. }
  1169. t = false;
  1170. break;
  1171. }
  1172. }
  1173. if (t) {
  1174. let obj : any = {};
  1175. obj.title = item.skuTitle
  1176. obj.subtitle = item.skuSubtitle
  1177. obj.materialSkuId = item.id
  1178. obj.isDeleted = 0
  1179. this.makeupList.push(obj);
  1180. nowData.push(obj);
  1181. }
  1182. };
  1183. (this as any).$refs.makeupTable.setValue(nowData) // 设置表格数据
  1184. if (names) {
  1185. this.$alert('商品 “' + names + '”已存在!', '提示', {
  1186. confirmButtonText: '确定',
  1187. });
  1188. }
  1189. }
  1190. })
  1191. }
  1192. //点击树获取数据
  1193. onChangeTree(e : any) {
  1194. this.categoryIds = e.id;
  1195. var ids:any = e.id;
  1196. if(e.id[0]==0) ids = 0;
  1197. let loading = this.$loading({ target: '.main-container' });
  1198. api.byCategoryPage({
  1199. categoryId: ids,
  1200. pageSize: 20,
  1201. pageNo: 1,
  1202. }, 'maindataMaterialCategory').then((res : any) => {
  1203. loading.close();
  1204. if (res.code === 200) {
  1205. (this.$refs.moduleView as any).setTableValue(res.data.records);
  1206. let page = {
  1207. pageNo: res.data.current, //当前页
  1208. pageSize: res.data.size, //每页条数
  1209. total: res.data.total //总条数
  1210. };
  1211. (this.$refs.moduleView as any).setPage(page);
  1212. }
  1213. }).catch(() => loading.close());
  1214. }
  1215. // 保存编辑/新增
  1216. doFormData() {
  1217. (this as any).$refs.form.validate().then(() => {
  1218. let query = (this as any).$refs.form.getValue();
  1219. console.log('物料信息 ==> ', query);
  1220. query.materialSpec = this.materialSpec; // 商品规格
  1221. query.attributeList = JSON.stringify(this.attributeList) // 物料属性
  1222. query.attributeId = this.attributeId // 物料属性ID
  1223. query.status = this.status; // 物料状态
  1224. query.tags = this.tagsData.join(","); // 标签
  1225. query.ismakeup = this.ismakeup; // 商品组合
  1226. query.issued = this.issued; // 是否公布
  1227. query.description = this.textarea; // 备注
  1228. let data : any = {}
  1229. // 多规格
  1230. if (query.materialSpec === 1) {
  1231. if (this.tableList.length <= 0 || this.attributeList.length <= 0) return (this as any).$message.warning('多规格商品,物料属性不能为空!');
  1232. console.log('多规格表格数据 ==> ', this.tableList);
  1233. for (let v of this.tableList) {
  1234. // if (!v.price) return this.$message.warning('物料属性价格必填');
  1235. // if (parseInt(v.price) <= 0) return this.$message.warning('物料属性价格不能小于1');
  1236. // if (!v.unit) return this.$message.warning('物料属性单位必填');
  1237. // if (!v.stock) return this.$message.warning('物料属性库存必填');
  1238. // if (parseInt(v.stock) <= 0) return this.$message.warning('物料属性库存必须为自然数');
  1239. // if (!v.shelfLife) return this.$message.warning('物料属性保质期必填');
  1240. // if (parseInt(v.shelfLife) <= 0) return this.$message.warning('物料属性保质期必须为自然数');
  1241. // if (!v.weight) return this.$message.warning('物料属性重量必填');
  1242. // if (parseInt(v.weight) <= 0) return this.$message.warning('物料属性重量不能小于1');
  1243. // if (!v.length) return this.$message.warning('物料属性长度必填');
  1244. // if (parseInt(v.length) <= 0) return this.$message.warning('物料属性长度不能小于1');
  1245. // if (!v.width) return this.$message.warning('物料属性宽度必填');
  1246. // if (parseInt(v.width) <= 0) return this.$message.warning('物料属性宽度不能小于1');
  1247. // if (!v.height) return this.$message.warning('物料属性高度必填');
  1248. // if (parseInt(v.height) <= 0) return this.$message.warning('物料属性高度不能小于1');
  1249. (this.$refs.table as any).validate();
  1250. if (!v.skuTitle) return this.$message.warning('物料标题必填');
  1251. if (!v.skuCode) return this.$message.warning('物料编码必填');
  1252. if (!v.barCode) return this.$message.warning('物料属性的69码-商品条码需必填');
  1253. if (!/^\d{1,32}$/.test(v.barCode)){
  1254. return this.$message.warning('69码-商品条码为数字,最大32位');
  1255. }
  1256. // if(v.weight&&v.weight!=0){
  1257. // v.weight = v.weight/1000
  1258. // }
  1259. // v.isDeleted = 0
  1260. v.ismakeup = this.ismakeup
  1261. };
  1262. data = { maindataMaterialReceiveParam: query, maindataMaterialSkus: this.tableList }
  1263. let newArray : any = []
  1264. let materialSpecData : any = []
  1265. let attributeLength = this.attributeList.length
  1266. this.tableList.map((v : any) => {
  1267. for (let kyes in v) {
  1268. if (kyes.indexOf('_field_name') != -1) {
  1269. let key = kyes.split('_field_name')[0]
  1270. newArray.push({ [key]: v[kyes] })
  1271. }
  1272. }
  1273. })
  1274. // console.log('newArray ==> ',newArray);
  1275. for (var i = 0; i < newArray.length; i += attributeLength) {
  1276. materialSpecData.push(newArray.slice(i, i + attributeLength));
  1277. }
  1278. // console.log('materialSpecData ==> ', materialSpecData);
  1279. data.maindataMaterialSkus.map((v : any, i : any) => {
  1280. if (materialSpecData[i]) v.materialSpec = JSON.stringify(materialSpecData[i])
  1281. })
  1282. } else { // 单规格
  1283. data = { maindataMaterialReceiveParam: query, maindataMaterialSkus: (this.$refs.singeTable as any).getValue() }
  1284. // console.log('单规格表格数据 ==> ', data.maindataMaterialSkus);
  1285. for (let v of data.maindataMaterialSkus) {
  1286. // if (!v.price) return this.$message.warning('物料价格必填');
  1287. // if (parseInt(v.price) <= 0) return this.$message.warning('物料价格不能小于1');
  1288. // if (parseInt(v.price) < 0) return this.$message.warning('物料价格不能为负数');
  1289. // if (!v.unit) return this.$message.warning('物料单位必填');
  1290. // if (!v.stock) return this.$message.warning('物料库存必填');
  1291. // if (parseInt(v.stock) <= 0) return this.$message.warning('物料库存必须为自然数');
  1292. // if (!v.shelfLife) return this.$message.warning('物料保质期必填');
  1293. // if (parseInt(v.shelfLife) <= 0) return this.$message.warning('物料保质期必须为自然数');
  1294. // if (!v.weight) return this.$message.warning('物料重量必填');
  1295. // if (parseInt(v.weight) <= 0) return this.$message.warning('物料重量不能小于1');
  1296. // if (!v.length) return this.$message.warning('物料长必填');
  1297. // if (parseInt(v.length) <= 0) return this.$message.warning('物料长不能小于1');
  1298. // if (!v.width) return this.$message.warning('物料宽必填');
  1299. // if (parseInt(v.width) <= 0) return this.$message.warning('物料宽不能小于1');
  1300. // if (!v.height) return this.$message.warning('物料高必填');
  1301. // if (parseInt(v.height) <= 0) return this.$message.warning('物料高不能小于1');
  1302. (this.$refs.singeTable as any).validate();
  1303. if (!v.skuTitle) return this.$message.warning('物料属性的标题需必填');
  1304. if (!v.skuCode) return this.$message.warning('物料属性的物料编码需必填');
  1305. if (!v.barCode) return this.$message.warning('物料属性的69码-商品条码需必填');
  1306. if (!/^\d{1,32}$/.test(v.barCode)){
  1307. return this.$message.warning('69码-商品条码为数字,最大32位');
  1308. }
  1309. // if(v.weight&&v.weight!=0){
  1310. // v.weight = v.weight/1000
  1311. // }
  1312. // v.isDeleted = 1
  1313. v.ismakeup = this.ismakeup
  1314. };
  1315. data.maindataMaterialSkus[0].isDeleted = 0;
  1316. data.maindataMaterialReceiveParam.attributeList = ""
  1317. }
  1318. if (this.ismakeup === 0) {
  1319. console.log('this.makeupList ==> ', this.makeupList);
  1320. if (this.makeupList.length <= 0) return this.$message.warning('请选择组合商品');
  1321. data.maindataMaterialLinks = this.makeupList;
  1322. // 表格删除
  1323. data.maindataMaterialLinks.map((v : any, i : any) => {
  1324. if (v.isDeleted === 1 && !v.id) {
  1325. data.maindataMaterialLinks.splice(i, 1)
  1326. }
  1327. });
  1328. }
  1329. console.log('data ==> ', data);
  1330. let loading = this.$loading({ target: '.main-container' });
  1331. if (this.isEdit) { // 编辑
  1332. api.updateList(data, 'maindataMaterial').then((res : any) => {
  1333. loading.close()
  1334. if (res.code === 200) {
  1335. this.isShow = 'home';
  1336. // (this as any).$refs.sideTree.request();
  1337. this.getDataList();
  1338. this.$message.success('保存成功');
  1339. }
  1340. }).catch(() => loading.close());
  1341. } else {// 新增
  1342. api.saveList(data, 'maindataMaterial').then((res : any) => {
  1343. loading.close()
  1344. if (res.code === 200) {
  1345. this.isShow = 'home';
  1346. // (this as any).$refs.sideTree.request();
  1347. this.getDataList();
  1348. this.$message.success('保存成功');
  1349. }
  1350. }).catch(() => loading.close());
  1351. }
  1352. }).catch(() => {});
  1353. }
  1354. // 打开新增
  1355. onAdd() {
  1356. this.isShow = 'add'; // 展示类型
  1357. this.selectValue = '' // 物料属性名称
  1358. this.towTable = '' // 表格数据
  1359. this.textarea = '' // 描述
  1360. this.tagsData = [] // 标签
  1361. this.attributeList = [] // 属性规格
  1362. this.tableList = [] // 表格数据
  1363. this.materialSpec = 0; // 单规格
  1364. this.status = 0; // 物料状态
  1365. this.ismakeup = 1; // 商品组合
  1366. this.makeupList = [] // 组合商品列表
  1367. this.issued = 0; // 是否公布
  1368. this.isSingle = true; // 显示单表格
  1369. this.isEdit = false; // 是否编辑
  1370. (this as any).$refs.byTool.setTool({ return: true, save: true });
  1371. this.$nextTick(() => {
  1372. (this as any).$refs.form.setValue(); // 设置表单数据
  1373. (this as any).$refs.singeTable.setValue([{}]) // 设置单表格数据
  1374. });
  1375. }
  1376. // 打开编辑
  1377. getDetail(e : any) {
  1378. // console.log('编辑 ==> ', e);
  1379. (this as any).$refs.byTool.setTool({ return: true, save: true, delete: true });
  1380. let loading = this.$loading({ target: '.my-container' });
  1381. api.single({ id: e.id }, 'maindataMaterial').then((v : any) => {
  1382. let data = v.data;
  1383. if (data.vmCategoryId) {
  1384. api.single({ id: data.vmCategoryId }, 'maindataMaterialVmcategory').then((res : any) => {
  1385. if (res.code === 200) {
  1386. if (res.data) data.vmCategoryName = res.data.name;
  1387. }
  1388. }).catch(() => loading.close());
  1389. }
  1390. if (data.organizationCategoryId) {
  1391. api.single({ id: data.organizationCategoryId }, 'maindataMaterialOrganizationCategory').then((res : any) => {
  1392. if (res.code === 200) {
  1393. if (res.data) data.organizationCategoryName = res.data.name;
  1394. }
  1395. }).catch(() => loading.close());
  1396. }
  1397. this.intercept = data.attributeId // 拦截物料属性判断
  1398. this.isEdit = true;
  1399. this.editInfo = data;
  1400. this.isShow = 'add';
  1401. // 标签
  1402. if (data.tags) {
  1403. this.tagsData = data.tags.split(",")
  1404. } else this.tagsData = [];
  1405. this.materialSpec = data.materialSpec
  1406. if(this.materialSpec == 1){
  1407. this.ismakeup = 1
  1408. }else{
  1409. this.ismakeup = 0
  1410. }
  1411. this.isSingle = data.materialSpec === 0 ? true : false;
  1412. if (data.attributeList) this.attributeList = JSON.parse(data.attributeList);
  1413. if (data.categoryId) {
  1414. api.single({ id: data.categoryId }, 'maindataMaterialCategory').then((res : any) => {
  1415. if (res.code === 200) data.categoryName = res.data.name;
  1416. if (data.attributeId) {
  1417. api.single({ id: data.attributeId }, 'maindataMaterialAttribute').then((p : any) => {
  1418. if (p.code === 200) {
  1419. if (p.data) this.selectValue = p.data.name
  1420. }
  1421. }).catch(() => loading.close());
  1422. }
  1423. other.selectByMaterialId({ id: data.id }, 'maindataMaterialSku').then((info : any) => {
  1424. if (info.code === 200) {
  1425. this.status = data.status
  1426. console.log(data.ismakeup);
  1427. this.ismakeup = data.ismakeup
  1428. if (data.ismakeup === 0 && data.maindataMaterialLinks.length > 0) {
  1429. (this as any).makeupList = data.maindataMaterialLinks;
  1430. setTimeout(() => {
  1431. (this as any).$refs.makeupTable.setValue(data.maindataMaterialLinks) // 设置组合表格数据
  1432. })
  1433. }
  1434. this.issued = data.issued
  1435. if (this.isSingle) {
  1436. this.selectValue = '' // 物料属性名称
  1437. this.towTable = '' // 表格数据
  1438. this.attributeList = []; // 属性规格
  1439. this.$nextTick(() => {
  1440. // console.log(info.data);
  1441. info.data.map((v : any, i : any) => {
  1442. // if(v.volume&&v.weight!='0.00'&&v.weight!=0&&v.weight!='0'){
  1443. // v.weight = parseFloat(v.weight)*1000
  1444. // }
  1445. if(v.volume&&v.volume!='0.00'&&v.volume!=0&&v.volume!='0'){
  1446. v.volume = parseFloat(v.volume).toFixed(2)
  1447. }
  1448. });
  1449. (this as any).$refs.singeTable.setValue(info.data);
  1450. });
  1451. } else {
  1452. this.forFun(this.attributeList[0], 0) // 生成sku
  1453. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1454. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1455. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1456. info.data.map((v : any, i : any) => {
  1457. v = Object.assign(v, skuRuleList[i])
  1458. v.dataIndex = i
  1459. // if(v.volume&&v.weight!='0.00'&&v.weight!=0&&v.weight!='0'){
  1460. // v.weight = parseFloat(v.weight)*1000
  1461. // }
  1462. if(v.volume&&v.volume!='0.00'&&v.volume!=0&&v.volume!='0'){
  1463. v.volume = parseFloat(v.volume).toFixed(2)
  1464. }
  1465. });
  1466. newColumns.map((v : any) => {
  1467. tableConfig.columns.unshift({
  1468. width: '80px',
  1469. title: v.title,
  1470. field: v.field,
  1471. })
  1472. });
  1473. this.tableList = (this as any).$lodash.cloneDeep(info.data);
  1474. // console.log('表格配置 ==> ', tableConfig);
  1475. console.log('skuRuleList ==> ', skuRuleList);
  1476. console.log('表格数据 ==> ', this.tableList);
  1477. this.setTableConfig = tableConfig;
  1478. this.$nextTick(() => {
  1479. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1480. (this as any).$refs.table.setValue(this.tableList) // 设置表格数据
  1481. });
  1482. }
  1483. }
  1484. (this as any).$refs.form.setValue(data)
  1485. loading.close()
  1486. }).catch(() => loading.close());
  1487. }).catch(() => loading.close());
  1488. } else {
  1489. // loading.close();
  1490. // this.$message.error('该数据没有物料分类id')
  1491. other.selectByMaterialId({ id: data.id }, 'maindataMaterialSku').then((info : any) => {
  1492. if (info.code === 200) {
  1493. this.status = data.status
  1494. console.log(data.ismakeup);
  1495. this.ismakeup = data.ismakeup
  1496. if (data.ismakeup === 0 && data.maindataMaterialLinks.length > 0) {
  1497. (this as any).makeupList = data.maindataMaterialLinks;
  1498. setTimeout(() => {
  1499. (this as any).$refs.makeupTable.setValue(data.maindataMaterialLinks) // 设置组合表格数据
  1500. })
  1501. }
  1502. this.issued = data.issued
  1503. if (this.isSingle) {
  1504. this.selectValue = '' // 物料属性名称
  1505. this.towTable = '' // 表格数据
  1506. this.attributeList = []; // 属性规格
  1507. this.$nextTick(() => {
  1508. (this as any).$refs.singeTable.setValue(info.data);
  1509. });
  1510. } else {
  1511. this.forFun(this.attributeList[0], 0) // 生成sku
  1512. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1513. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1514. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1515. info.data.map((v : any, i : any) => {
  1516. v = Object.assign(v, skuRuleList[i])
  1517. v.dataIndex = i
  1518. });
  1519. newColumns.map((v : any) => {
  1520. tableConfig.columns.unshift({
  1521. width: '80px',
  1522. title: v.title,
  1523. field: v.field,
  1524. })
  1525. });
  1526. this.tableList = (this as any).$lodash.cloneDeep(info.data);
  1527. // console.log('表格配置 ==> ', tableConfig);
  1528. console.log('skuRuleList ==> ', skuRuleList);
  1529. console.log('表格数据 ==> ', this.tableList);
  1530. this.setTableConfig = tableConfig;
  1531. this.$nextTick(() => {
  1532. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1533. (this as any).$refs.table.setValue(this.tableList) // 设置表格数据
  1534. });
  1535. }
  1536. }
  1537. (this as any).$refs.form.setValue(data)
  1538. loading.close()
  1539. }).catch(() => loading.close());
  1540. }
  1541. }).catch(() => loading.close());
  1542. }
  1543. // 同步金蝶物料
  1544. syncSystem() {
  1545. (this as any).dateDialogVisible = true
  1546. }
  1547. dateConfirm(){
  1548. if((this as any).stime){
  1549. (this as any).dateLoading = true;
  1550. var data = {
  1551. stime: (this as any).stime,
  1552. etime: (this as any).etime
  1553. }
  1554. console.log(data)
  1555. api.syncMaterialByKingdeeToOms(data).then((res : any) => {
  1556. if(res.code === 200){
  1557. (this as any).dateDialogVisible = false;
  1558. (this as any).dateLoading = false;
  1559. this.$message.success('同步金蝶物料成功');
  1560. }else{
  1561. (this as any).dateLoading = false;
  1562. this.$message.error(res.msg);
  1563. }
  1564. }).catch(()=>{
  1565. (this as any).dateLoading = false;
  1566. })
  1567. }else{
  1568. this.$message.warning('请选择时间');
  1569. }
  1570. }
  1571. // 立即生成
  1572. generateNow() {
  1573. this.forFun(this.attributeList[0], 0) // 生成sku
  1574. let newArray : any = []
  1575. let materialSpecData : any = []
  1576. let attributeLength = this.attributeList.length
  1577. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1578. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1579. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1580. let tableList = (this as any).$refs.table.getValue();
  1581. tableList.map((v : any) => {
  1582. for (let key in v) {
  1583. if (key.indexOf('_field_name') != -1) {
  1584. delete v[key]
  1585. }
  1586. }
  1587. })
  1588. skuRuleList.map((v : any) => {
  1589. for (let kyes in v) {
  1590. if (kyes.indexOf('_field_name') != -1) {
  1591. let key = kyes.split('_field_name')[0]
  1592. newArray.push({ [key]: v[kyes] })
  1593. }
  1594. }
  1595. })
  1596. // console.log('skuRuleList ==> ', skuRuleList);
  1597. for (var i = 0; i < newArray.length; i += attributeLength) {
  1598. materialSpecData.push(newArray.slice(i, i + attributeLength));
  1599. }
  1600. // console.log('materialSpecData ==> ', materialSpecData);
  1601. skuRuleList.map((v : any, i : any) => {
  1602. v.materialSpec = JSON.stringify(materialSpecData[i]);
  1603. v.dataIndex = i;
  1604. v.isDeleted = 0;
  1605. if (tableList[i] && v.materialSpec.indexOf(tableList[i].materialSpec != -1)) {
  1606. v = Object.assign(v, tableList[i])
  1607. };
  1608. })
  1609. newColumns.map((v : any) => {
  1610. tableConfig.columns.unshift({
  1611. width: '80px',
  1612. title: v.title,
  1613. field: v.field,
  1614. })
  1615. });
  1616. console.log('旧表格数据 ==> ', tableList);
  1617. console.log('新表格数据 ==> ', skuRuleList);
  1618. this.tableList = skuRuleList;
  1619. this.setTableConfig = tableConfig;
  1620. this.$nextTick(() => {
  1621. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1622. (this as any).$refs.table.setValue(this.tableList); // 设置表格数据
  1623. });
  1624. }
  1625. // 更换物料属性数据
  1626. getSelectValue(e : any) {
  1627. if (this.intercept === e) return console.log('拦截!');
  1628. this.$confirm('确定更换物料属性吗?确定之后原表格数据会被清除', '注意', {
  1629. confirmButtonText: '确定',
  1630. cancelButtonText: '取消',
  1631. type: 'warning',
  1632. center: true
  1633. }).then(() => {
  1634. api.single({ id: e }, 'maindataMaterialAttribute').then((res : any) => {
  1635. if (res.code === 200) {
  1636. this.selectList.map((v : any) => {
  1637. if (v.id === e) {
  1638. v.id = e
  1639. this.selectValue = v.name
  1640. }
  1641. });
  1642. this.intercept = e
  1643. this.attributeList = JSON.parse(res.data.attributeValue);
  1644. this.attributeId = e
  1645. this.forFun(this.attributeList[0], 0) // 生成sku
  1646. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1647. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1648. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1649. let giveInfo = (this as any).$refs.form.getValue();
  1650. skuRuleList.map((v : any, i : any) => {
  1651. v.dataIndex = i;
  1652. v.isDeleted = 0;
  1653. v.skuTitle = giveInfo.name;
  1654. v.skuSubtitle = giveInfo.shortName;
  1655. v.price = giveInfo.basePrice
  1656. })
  1657. newColumns.map((v : any) => {
  1658. tableConfig.columns.unshift({
  1659. width: '80px',
  1660. title: v.title,
  1661. field: v.field,
  1662. })
  1663. });
  1664. console.log('表格配置 ==> ', tableConfig);
  1665. console.log('表格数据 ==> ', skuRuleList);
  1666. this.setTableConfig = tableConfig;
  1667. this.tableList = skuRuleList;
  1668. this.$nextTick(() => {
  1669. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1670. (this as any).$refs.table.setValue(skuRuleList); // 设置表格数据
  1671. });
  1672. }
  1673. }).catch(() => {});
  1674. }).catch(() => { });
  1675. }
  1676. // 关联金蝶财务系统物料选择
  1677. handleSelectionChange(row: any){
  1678. console.log(row)
  1679. this.tableRadio = row
  1680. }
  1681. // 关联金蝶财务系统物料列表搜索
  1682. tableSearchOnSubmit(){
  1683. this.getFinancialCode()
  1684. }
  1685. // 关联金蝶财务系统物料列表重置
  1686. resetTableSearch(){
  1687. var t = new Date();
  1688. var y = t.getFullYear();
  1689. var m:any = t.getMonth()+1;
  1690. if(m<10){m='0'+m}
  1691. var d:any = t.getDate()
  1692. if(d<10){d='0'+d}
  1693. this.tableSearchForm.fname = null;
  1694. this.tableSearchForm.fnumber = null;
  1695. this.tableSearchForm.stime = '2020-01-01';
  1696. this.tableSearchForm.etime = y+'-'+m+'-'+d;
  1697. this.getFinancialCode()
  1698. }
  1699. // 关联金蝶财务系统物料表格分页
  1700. currentChange(e: any){
  1701. this.newtableData = this.tableData.slice((e-1)*this.tablePageSize, e*this.tablePageSize)
  1702. }
  1703. // 打开关联金蝶财务系统物料选择
  1704. openVxeData(){
  1705. this.vxeValue = true;
  1706. if(this.tableData.length==0){
  1707. setTimeout(()=>{
  1708. this.getFinancialCode();
  1709. },0)
  1710. }
  1711. }
  1712. // 获取关联金蝶财务系统物料列表
  1713. getFinancialCode(){
  1714. this.tableloading = true;
  1715. api.getFinancialCode(this.tableSearchForm).then((res : any) => {
  1716. if(res.code==200){
  1717. this.tableloading = false;
  1718. this.tableData = res.data
  1719. if(this.tableSearchForm.fname || this.tableSearchForm.fnumber){
  1720. let newData = [];
  1721. if(this.tableSearchForm.fname){
  1722. newData = this.tableData.filter((v : any) => v.fname.indexOf(this.tableSearchForm.fname) != -1);
  1723. }
  1724. if(this.tableSearchForm.fnumber){
  1725. newData = this.tableData.filter((v : any) => v.fnumber.indexOf(this.tableSearchForm.fnumber) != -1);
  1726. }
  1727. if(this.tableSearchForm.fname && this.tableSearchForm.fnumber){
  1728. newData = this.tableData.filter((v : any) => v.fname.indexOf(this.tableSearchForm.fname) != -1 && v.fnumber.indexOf(this.tableSearchForm.fnumber) != -1);
  1729. }
  1730. this.tableDataTotal = newData.length
  1731. this.newtableData = newData.slice(0, this.tablePageNum*this.tablePageSize)
  1732. }else{
  1733. this.tableDataTotal = this.tableData.length
  1734. this.newtableData = this.tableData.slice(0, this.tablePageNum*this.tablePageSize)
  1735. }
  1736. }else{
  1737. this.$message.error(res.msg);
  1738. this.tableloading = false;
  1739. }
  1740. }).catch(() => {});
  1741. }
  1742. // 确定关联金蝶财务系统物料
  1743. doConfirm() {
  1744. if(JSON.stringify(this.tableRadio) === "{}" || this.tableRadio === null || this.tableRadio === {}) { return this.$message.warning('请选择物料'); }
  1745. // 表单赋值赋值
  1746. var val2 = (this as any).$refs.form.getValue();
  1747. val2.name = this.tableRadio.fname;
  1748. val2.shortName = this.tableRadio.fname;
  1749. // 物料属性赋值
  1750. var val = (this as any).$refs.singeTable.getValue();
  1751. if(JSON.stringify(val[0]) === "{}" || val[0] === null){
  1752. val = [{
  1753. skuTitle: this.tableRadio.fname,
  1754. skuSubtitle: this.tableRadio.fname,
  1755. // skuCode: '',
  1756. financialCode: this.tableRadio.fnumber,
  1757. // price: '0',
  1758. unit: this.tableRadio.fbaseUnitName,
  1759. unitCode: this.tableRadio.fbaseUnitCode,
  1760. // shelfLife: '0',
  1761. // weight: '0',
  1762. // length: '0',
  1763. // width: '0',
  1764. // height: '0',
  1765. // volume: '0',
  1766. }];
  1767. }else{
  1768. val[0].skuTitle = this.tableRadio.fname;
  1769. val[0].skuSubtitle = this.tableRadio.fname;
  1770. val[0].financialCode = this.tableRadio.fnumber;
  1771. val[0].unit = this.tableRadio.fbaseUnitName;
  1772. val[0].unitCode = this.tableRadio.fbaseUnitCode;
  1773. }
  1774. (this as any).$refs.singeTable.setValue(val);
  1775. (this as any).$refs.form.setValue(val2);
  1776. this.vxeValue = false;
  1777. }
  1778. // 切换组合商品
  1779. openMakeup() {
  1780. (this.$refs.product as any).setShow(true); // 打开sku弹窗
  1781. }
  1782. // 切换商品规格
  1783. changeSingle() {
  1784. if(this.materialSpec == 1){
  1785. this.ismakeup = 1
  1786. }
  1787. if (this.isSingle) {
  1788. if ((this as any).$refs.singeTable) this.singeTable = (this as any).$refs.singeTable.getValue()
  1789. this.isSingle = false;
  1790. this.$nextTick(() => {
  1791. // 设置表格数据
  1792. if (this.towTable) {
  1793. if ((this as any).$refs.table) {
  1794. this.tableList = this.towTable;
  1795. (this as any).$refs.table.setConfig(this.setTableConfig); // 设置表格配置
  1796. (this as any).$refs.table.setValue(this.towTable); // 设置表格数据
  1797. }
  1798. }
  1799. });
  1800. } else {
  1801. if ((this as any).$refs.table) this.towTable = (this as any).$refs.table.getValue()
  1802. this.isSingle = true;
  1803. this.$nextTick(() => {
  1804. // 设置单表格数据
  1805. if (this.singeTable) {
  1806. console.log('单表格数据 ==> ', this.singeTable);
  1807. (this as any).$refs.singeTable.setValue(this.singeTable);
  1808. } else (this as any).$refs.singeTable.setValue([{}]);
  1809. });
  1810. }
  1811. }
  1812. // 添加规格
  1813. showInput(index : any) {
  1814. this.$confirm('确定添加吗!确定后将可能影响原表格数据', '注意', {
  1815. confirmButtonText: '确定',
  1816. cancelButtonText: '取消',
  1817. type: 'warning',
  1818. center: true
  1819. }).then(() => {
  1820. let inputValue = (this as any).$refs['getValue_' + index][0].getValue();
  1821. if (!inputValue) return (this as any).$message.warning('请输入内容');
  1822. if (!/^\S*$/.test(inputValue)) return (this as any).$message.warning('输入内容不能有空格');
  1823. if (this.attributeList[index].list.indexOf(inputValue) !== -1) return (this as any).$refs['getValue_' + index][0].clearValue();
  1824. if (inputValue) {
  1825. this.attributeList[index].list.push(inputValue);
  1826. }
  1827. (this as any).$refs['getValue_' + index][0].clearValue();
  1828. this.generateNow();
  1829. this.$message.success('添加成功');
  1830. }).catch(() => this.$message.info('已取消添加'));
  1831. }
  1832. // 添加sku规格
  1833. doComfirm() {
  1834. if (!this.normsValue || !this.norms) return (this as any).$message.warning('请添加完整的规格');
  1835. if (!/^\S*$/.test(this.normsValue) || !/^\S*$/.test(this.norms)) return this.$message.warning('输入内容不能有空格');
  1836. this.$confirm('确定添加吗!确定后将可能影响原表格数据', '注意', {
  1837. confirmButtonText: '确定',
  1838. cancelButtonText: '取消',
  1839. type: 'warning',
  1840. center: true
  1841. }).then(() => {
  1842. let obj : any = {
  1843. title: this.norms,
  1844. field: this.norms + '_field_name',
  1845. list: [this.normsValue]
  1846. };
  1847. this.attributeList.push(obj);
  1848. this.norms = '';
  1849. this.normsValue = '';
  1850. this.isAdd = false;
  1851. this.generateNow();
  1852. this.$message.success('添加成功');
  1853. }).catch(() => this.$message.info('已取消添加'));
  1854. }
  1855. // 监听表格数据
  1856. getInputValue(e : any) {
  1857. // console.log('监听表格 ==> ', e);
  1858. if (e.length && e.width && e.height) {
  1859. e.volume = (e.length * e.width * e.height).toFixed(2);
  1860. }
  1861. }
  1862. // 监听组合商品表格数据
  1863. getMakeupTableValue(e : any) {
  1864. // console.log('监听表格 ==> ', e);
  1865. // console.log(this.productDataList)
  1866. this.volumeCount()
  1867. }
  1868. volumeCount(){
  1869. let nowData:any = (this.$refs.makeupTable as any).getValue();
  1870. var data:any = {
  1871. weight: 0,
  1872. length: 0,
  1873. width: 0,
  1874. height: 0
  1875. }
  1876. for (let i in this.productDataList) {
  1877. for (let j in nowData) {
  1878. if(this.productDataList[i].id==nowData[j].materialSkuId){
  1879. var number:any = 1;
  1880. if(nowData[j].number){
  1881. var number:any = parseFloat(nowData[j].number).toFixed(2);
  1882. }
  1883. if(this.productDataList[i].weight){
  1884. var weight:any = parseFloat(this.productDataList[i].weight).toFixed(2);
  1885. data.weight += weight*number;
  1886. }
  1887. if(this.productDataList[i].length){
  1888. var length:any = parseFloat(this.productDataList[i].length).toFixed(2);
  1889. data.length += length*number;
  1890. }
  1891. if(this.productDataList[i].width){
  1892. var width:any = parseFloat(this.productDataList[i].width).toFixed(2);
  1893. data.width += width*number;
  1894. }
  1895. if(this.productDataList[i].height){
  1896. var height:any = parseFloat(this.productDataList[i].height).toFixed(2);
  1897. data.height += height*number;
  1898. }
  1899. }
  1900. }
  1901. }
  1902. var val = (this as any).$refs.singeTable.getValue();
  1903. val[0].weight = data.weight;
  1904. val[0].length = data.length;
  1905. val[0].width = data.width;
  1906. val[0].height = data.height;
  1907. (this as any).$refs.singeTable.setValue(val);
  1908. }
  1909. // 排序生成
  1910. forFun(data : any, i : number, v ?: any) {
  1911. if (data.list) {
  1912. let d : Array<any> = [];
  1913. data.list.forEach((item : any) => {
  1914. if (i == 0) { // 第一次循环
  1915. let obj : any = {}
  1916. obj[data.field] = item
  1917. d.push(obj);
  1918. } else {
  1919. v.forEach((ele : any) => {
  1920. let obj : any = {};
  1921. obj = (this as any).$lodash.clone(ele);
  1922. obj[data.field] = item
  1923. d.push(obj);
  1924. });
  1925. }
  1926. });
  1927. i++
  1928. if (this.attributeList[i]) {
  1929. this.forFun(this.attributeList[i], i, d);
  1930. }
  1931. else {
  1932. this.skuRuleList = d;
  1933. }
  1934. }
  1935. }
  1936. // 添加标签
  1937. getTagsValue() {
  1938. let value = (this as any).$refs.tagsValue.getValue().trim();
  1939. if (!value) return this.$message.warning('请输入标签值');
  1940. this.tagsData.push(value);
  1941. (this as any).$refs.tagsValue.clearValue();
  1942. }
  1943. // 删除标签
  1944. handleClose2(index : any) {
  1945. this.$confirm('确定删除吗!', '注意', {
  1946. confirmButtonText: '确定',
  1947. cancelButtonText: '取消',
  1948. type: 'warning',
  1949. center: true
  1950. }).then(() => {
  1951. this.tagsData.splice(index, 1)
  1952. this.$message.success('删除成功');
  1953. }).catch(() => this.$message.info('已取消删除'));
  1954. }
  1955. // 删除标签
  1956. handleClose(tag : any, index : any) {
  1957. this.$confirm('确定删除吗!确定后将可能影响原表格数据', '注意', {
  1958. confirmButtonText: '确定',
  1959. cancelButtonText: '取消',
  1960. type: 'warning',
  1961. center: true
  1962. }).then(() => {
  1963. this.attributeList[index].list.splice(this.attributeList[index].list.indexOf(tag), 1);
  1964. this.generateNow();
  1965. this.$message.success('删除成功');
  1966. }).catch(() => this.$message.info('已取消删除'));
  1967. }
  1968. // 删除数组
  1969. closeGroup(index : any) {
  1970. this.$confirm('确定删除吗!确定后将可能影响原表格数据', '注意', {
  1971. confirmButtonText: '确定',
  1972. cancelButtonText: '取消',
  1973. type: 'warning',
  1974. center: true
  1975. }).then(() => {
  1976. this.attributeList.splice(index, 1);
  1977. this.generateNow();
  1978. this.$message.success('删除成功');
  1979. }).catch(() => this.$message.info('已取消删除'));
  1980. }
  1981. // 删除表格数据
  1982. doDeleteTable(item : any) {
  1983. if((this as any).tableList.length>1){
  1984. this.$confirm('确定删除吗!', '注意', {
  1985. confirmButtonText: '确定',
  1986. cancelButtonText: '取消',
  1987. type: 'warning',
  1988. center: true
  1989. }).then(() => {
  1990. // console.log(this.tableList);
  1991. (this as any).tableList.map((v : any) => {
  1992. if (v.dataIndex === item.dataIndex) v.isDeleted = 1;
  1993. })
  1994. let filterList = this.tableList.filter((v : any) => v.isDeleted !== 1);
  1995. (this as any).$refs.table.setValue(filterList); // 设置表格数据
  1996. this.$message.success('删除成功');
  1997. }).catch(() => this.$message.info('已取消删除'));
  1998. }else{
  1999. this.$message.warning('物料属性不能为空,无法删除!')
  2000. }
  2001. }
  2002. // 获取物料属性
  2003. getAttribute() {
  2004. api.pageList({
  2005. pageSize: 999,
  2006. status: 0
  2007. }, 'maindataMaterialAttribute').then((res : any) => {
  2008. if (res.code === 200) {
  2009. this.selectList = res.data.records
  2010. } else this.$message.error(res.msg);
  2011. }).catch(() => {});
  2012. }
  2013. // 获取列表数据
  2014. getDataList() {
  2015. if (!this.$refs.moduleView) {
  2016. if (this.timeNum > 5) {
  2017. clearInterval(this.timer)
  2018. }
  2019. this.timeNum++;
  2020. return
  2021. }
  2022. clearInterval(this.timer)
  2023. let query = (this.$refs.moduleView as any).getQuery();
  2024. if (this.categoryIds) query.categoryIds = this.categoryIds;
  2025. console.log('表单字段 ==> ', query);
  2026. this.getPageList(query)
  2027. }
  2028. getPageList(query : any) {
  2029. let loading = this.$loading({ target: '.main-container' });
  2030. api.treeList('maindataMaterialCategory').then((treeRes : any) => {
  2031. if(treeRes.code==200){
  2032. api.pageList(query, 'maindataMaterial').then((res : any) => {
  2033. if (res.code === 200) {
  2034. var data:any = [{
  2035. id: 0,
  2036. name: '物料分类',
  2037. children: treeRes.data
  2038. }];
  2039. (this as any).$refs.sideTree.setData(data);
  2040. (this.$refs.moduleView as any).setTableValue(res.data.records);
  2041. let page = {
  2042. pageNo: res.data.current, //当前页
  2043. pageSize: res.data.size, //每页条数
  2044. total: res.data.total //总条数
  2045. };
  2046. (this.$refs.moduleView as any).setPage(page);
  2047. loading.close();
  2048. } else this.$message.error(res.msg);
  2049. }).catch(() => loading.close());
  2050. }
  2051. }).catch(() => loading.close());
  2052. }
  2053. // 工具栏方法
  2054. clickHandle(e : any) {
  2055. if (e === 'onAdd') this.onAdd();
  2056. if (e === 'onDelete') this.doDelete();
  2057. }
  2058. // 内页工具栏方法
  2059. insideTools(e : any) {
  2060. console.log(e);
  2061. if (e === 'onReturn') this.isShow = 'home';
  2062. if (e === 'onSave') this.doFormData();
  2063. if (e === 'onDelete') this.pageDelete(this.editInfo);
  2064. }
  2065. // 组合商品删除
  2066. deleteMakeup(item : any) {
  2067. this.$confirm('确定删除吗', '注意', {
  2068. confirmButtonText: '确定',
  2069. cancelButtonText: '取消',
  2070. type: 'warning',
  2071. center: true
  2072. }).then((res) => {
  2073. console.log(res)
  2074. let data = (this.$refs.makeupTable as any).getValue();// 获取表格数据
  2075. // let i = -1;
  2076. // let j = -1;
  2077. // for (const v of data) {
  2078. // i++;
  2079. // if (v.id == item.id) {
  2080. // break
  2081. // }
  2082. // };
  2083. // for (const v of this.makeupList) {
  2084. // j++;
  2085. // if (v.id == item.id && item.isDeleted === 0) {
  2086. // break
  2087. // }
  2088. // };
  2089. // this.makeupList[j].isDeleted = 1;
  2090. // data.splice(i, 1);
  2091. // this.productDataList.splice(i, 1);
  2092. for (var i = 0; i < data.length; i++) {
  2093. if(data[i].materialSkuId == item.materialSkuId){
  2094. if(item.isDeleted == 0){
  2095. this.makeupList[i].isDeleted = 1;
  2096. }
  2097. data.splice(i, 1);
  2098. this.productDataList.splice(i, 1)
  2099. }
  2100. };
  2101. (this.$refs.makeupTable as any).setValue(data);// 设置表格数据
  2102. this.$message.success('删除成功');
  2103. // setTimeout(()=> {
  2104. // this.volumeCount()
  2105. // }, 10);
  2106. }).catch((err) => {
  2107. this.$message.info('已取消删除');
  2108. console.log(err)
  2109. });
  2110. }
  2111. // 内页删除
  2112. pageDelete(item : any) {
  2113. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  2114. confirmButtonText: '确定',
  2115. cancelButtonText: '取消',
  2116. type: 'warning',
  2117. center: true
  2118. }).then(() => {
  2119. other.deleteSpuAndSku({ ids: item.id }, 'maindataMaterial').then((res : any) => {
  2120. if (res.code === 200) {
  2121. this.$message.success('删除成功');
  2122. this.isShow = 'home';
  2123. // (this as any).$refs.sideTree.request();
  2124. this.getDataList();
  2125. } else this.$message.error(res.msg);
  2126. }).catch(() => {});
  2127. }).catch(() => this.$message.info('已取消删除'));
  2128. }
  2129. // 工具栏删除
  2130. doDelete() {
  2131. let selectData = (this.$refs.moduleView as any).getSelectData()
  2132. let ids = '';
  2133. if (selectData.length > 0) {
  2134. selectData.map((v : any) => {
  2135. ids += v.id + ','
  2136. })
  2137. } else return this.$message({ type: 'warning', message: '请选择删除数据' })
  2138. ids = ids.slice(0, ids.length - 1);
  2139. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  2140. confirmButtonText: '确定',
  2141. cancelButtonText: '取消',
  2142. type: 'warning',
  2143. center: true
  2144. }).then(() => {
  2145. other.deleteSpuAndSku({ ids: ids }, 'maindataMaterial').then((res : any) => {
  2146. if (res.code === 200) {
  2147. // (this as any).$refs.sideTree.request();
  2148. this.getDataList();
  2149. this.$message.success('删除成功');
  2150. } else this.$message.error(res.msg);
  2151. }).catch(() => {});
  2152. }).catch(() => this.$message.info('已取消删除'));
  2153. }
  2154. // 操作删除
  2155. doDelete2(item : any) {
  2156. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  2157. confirmButtonText: '确定',
  2158. cancelButtonText: '取消',
  2159. type: 'warning',
  2160. center: true
  2161. }).then(() => {
  2162. other.deleteSpuAndSku({ ids: item.id }, 'maindataMaterial').then((res : any) => {
  2163. if (res.code === 200) {
  2164. // (this as any).$refs.sideTree.request();
  2165. this.getDataList();
  2166. this.$message.success('删除成功');
  2167. } else this.$message.error(res.msg);
  2168. }).catch(() => {});
  2169. }).catch(() => this.$message.info('已取消删除'));
  2170. }
  2171. // 刷新
  2172. onRefresh() {
  2173. (this as any).$refs.moduleView.clearSearch();
  2174. // (this as any).$refs.sideTree.request();
  2175. this.categoryIds = '';
  2176. this.getDataList();
  2177. }
  2178. }
  2179. </script>
  2180. <style>
  2181. .el-tree{max-height: 100%;overflow-y: auto;}
  2182. </style>
  2183. <style lang="scss" scoped>
  2184. .my-container {
  2185. width: 100%;
  2186. box-sizing: border-box;
  2187. display: flex;
  2188. padding: 16px;
  2189. height: 100%;
  2190. .bill-left {
  2191. position: relative;
  2192. border-right: solid #EEE 1px;
  2193. padding-right: 16px;
  2194. flex-shrink: 0;
  2195. .bill-tab {
  2196. width: 210px;
  2197. height: 100%;
  2198. transition: all .5s;
  2199. overflow: auto;
  2200. }
  2201. .tab-title {
  2202. font-size: 16px;
  2203. padding-bottom: 16px;
  2204. width: 200px;
  2205. }
  2206. }
  2207. .item-tab {
  2208. margin-right: 16px;
  2209. }
  2210. .bill-main {
  2211. width: calc(100% - 16px);
  2212. box-sizing: border-box;
  2213. margin-left: 16px;
  2214. position: relative;
  2215. height: 100%;
  2216. overflow-y: hidden;
  2217. }
  2218. .detil {
  2219. width: 100%;
  2220. .box-shadow {
  2221. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  2222. padding: 20px;
  2223. border-radius: 4px;
  2224. border: 1px solid #e6ebf5;
  2225. background-color: #fff;
  2226. overflow: hidden;
  2227. color: #303133;
  2228. -webkit-transition: .3s;
  2229. transition: .3s;
  2230. margin-top: 20px;
  2231. }
  2232. }
  2233. }
  2234. </style>