index.vue 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502
  1. <template>
  2. <el-card shadow="always" :body-style="{ padding: '10px' }">
  3. <div class="app-container">
  4. <el-dialog
  5. :title="upload.title"
  6. :visible.sync="upload.open"
  7. width="400px"
  8. append-to-body
  9. >
  10. <el-upload
  11. ref="upload"
  12. :limit="1"
  13. accept=".xlsx, .xls"
  14. :headers="upload.headers"
  15. :action="
  16. upload.url +
  17. '?updateSupport=' +
  18. upload.updateSupport +
  19. '&tableName=' +
  20. tableName +
  21. '&sqlKey=' +
  22. tableKey
  23. "
  24. v-loading="upload.isUploading"
  25. :disabled="upload.isUploading"
  26. :on-progress="handleFileUploadProgress"
  27. :on-success="handleFileSuccess"
  28. :auto-upload="false"
  29. :onChange="handleChange"
  30. drag
  31. >
  32. <i class="el-icon-upload"></i>
  33. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  34. <div class="el-upload__tip text-center" slot="tip">
  35. <!-- <div class="el-upload__tip" slot="tip">-->
  36. <!-- <el-checkbox v-model="upload.updateSupport"/>-->
  37. <!-- 是否更新已经存在的用户数据-->
  38. <!-- </div>-->
  39. <span>仅允许导入xls、xlsx格式文件。</span>
  40. <el-link
  41. type="primary"
  42. :underline="false"
  43. style="font-size: 12px; vertical-align: baseline"
  44. @click="importTemplate"
  45. >下载模板
  46. </el-link>
  47. </div>
  48. </el-upload>
  49. <div slot="footer" class="dialog-footer">
  50. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  51. <el-button @click="upload.open = false">取 消</el-button>
  52. </div>
  53. </el-dialog>
  54. <Queryfrom
  55. :form-vals="templateInfo.where"
  56. :statisticList="statisticList"
  57. :showCount="showCount"
  58. :showSearch="showSearch"
  59. @getList="getList"
  60. ref="mychild"
  61. />
  62. <el-row :gutter="10" class="mb8">
  63. <el-col :span="1.5">
  64. <el-button
  65. type="primary"
  66. plain
  67. icon="el-icon-plus"
  68. size="mini"
  69. v-hasPermi="['system:RetailOrder:insert']"
  70. @click="addHandler"
  71. >新增
  72. </el-button>
  73. </el-col>
  74. <!-- <el-col :span="1.5" v-if="false">
  75. <el-button
  76. type="success"
  77. plain
  78. icon="el-icon-edit"
  79. size="mini"
  80. :disabled="single"
  81. @click="handleUpdate"
  82. >修改
  83. </el-button>
  84. </el-col> -->
  85. <el-col :span="1.5">
  86. <el-button
  87. type="danger"
  88. plain
  89. icon="el-icon-delete"
  90. size="mini"
  91. :disabled="multiple"
  92. v-hasPermi="['system:RetailOrder:remove']"
  93. @click="myDeleteHandler"
  94. >删除
  95. </el-button>
  96. </el-col>
  97. <!-- <el-col :span="1.5">
  98. <el-button
  99. plain
  100. icon="el-icon-upload2"
  101. size="mini"
  102. @click="upload.open = true"
  103. >导入
  104. </el-button>
  105. </el-col>
  106. <el-col :span="1.5">
  107. <el-button
  108. type="warning"
  109. plain
  110. icon="el-icon-download"
  111. size="mini"
  112. @click="handleExport"
  113. >导出
  114. </el-button>
  115. </el-col>
  116. <right-toolbar
  117. style="float: right"
  118. :showCount.sync="showCount"
  119. :showSearch.sync="showSearch"
  120. :counts="true"
  121. @queryTable="pageList"
  122. ></right-toolbar> -->
  123. <el-radio-group
  124. style="float: right; margin-right: 100px"
  125. v-model="queryParams.status"
  126. @change="orderStartChange"
  127. size="mini"
  128. >
  129. <!-- 未提交/和待出库 -->
  130. <el-radio-button :label="100">未完成</el-radio-button>
  131. <el-radio-button :label="200">已完成</el-radio-button>
  132. </el-radio-group>
  133. </el-row>
  134. <el-table
  135. v-loading="loading"
  136. :data="tableList"
  137. @selection-change="handleSelectionChange"
  138. ref="tableRef"
  139. :cell-style="cellStyle"
  140. row-key="id"
  141. >
  142. <el-table-column
  143. type="selection"
  144. width="55"
  145. :reserve-selection="true"
  146. align="center"
  147. >
  148. </el-table-column>
  149. <!-- <el-table-column type="selection" width="55" /> -->
  150. <el-table-column prop="saleNo" align="center" label="合同号" />
  151. <el-table-column prop="saleDate" align="center" label="日期" />
  152. <el-table-column prop="customName" align="center" label="客户名称" />
  153. <el-table-column prop="deliveryDate" align="center" label="交货日期" />
  154. <el-table-column prop="saleLeadTime" align="center" label="交货天数" />
  155. <el-table-column
  156. prop="saleAmountInWords"
  157. align="center"
  158. label="合计金额(大写)"
  159. />
  160. <el-table-column label="付款方式" align="center" prop="salePayType">
  161. <template slot-scope="scope">
  162. {{ getDictLabel(scope.row.salePayType, "payment_method") }}
  163. </template>
  164. </el-table-column>
  165. <el-table-column prop="status" align="center" label="状态">
  166. <template slot-scope="scope">
  167. <el-tag :type="scope.row.listClass">{{
  168. getDictLabel(scope.row.status, "sales_order_status")
  169. }}</el-tag>
  170. </template>
  171. </el-table-column>
  172. <el-table-column prop="salesman" align="center" label="销售员" />
  173. <el-table-column prop="remark" align="center" label="备注" />
  174. <el-table-column label="操作" align="center">
  175. <template slot-scope="scope">
  176. <el-dropdown>
  177. <el-button type="warning" plain size="small">
  178. 操作<i class="el-icon-arrow-down el-icon--right"></i>
  179. </el-button>
  180. <el-dropdown-menu slot="dropdown">
  181. <el-dropdown-item v-show="scope.row.status != 6">
  182. <el-button
  183. size="mini"
  184. type="text"
  185. icon="el-icon-edit"
  186. v-hasPermi="['system:RetailOrder:update']"
  187. @click="handleUpdate(scope.row)"
  188. >修改
  189. </el-button>
  190. </el-dropdown-item>
  191. <el-dropdown-item v-show="scope.row.status == 9">
  192. <el-button
  193. size="mini"
  194. type="text"
  195. icon="el-icon-edit"
  196. v-hasPermi="['system:RetailOrder:update']"
  197. @click="handleComplate(scope.row)"
  198. >完成
  199. </el-button>
  200. </el-dropdown-item>
  201. <el-dropdown-item>
  202. <el-button
  203. size="mini"
  204. type="text"
  205. icon="el-icon-tickets"
  206. v-hasPermi="['system:RetailOrder:info']"
  207. @click="handlePrint(scope.row)"
  208. >详情
  209. </el-button>
  210. </el-dropdown-item>
  211. <!-- <el-dropdown-item>
  212. <el-button
  213. size="mini"
  214. type="text"
  215. icon="el-icon-folder-checked"
  216. v-hasPermi="['system:RetailOrder:submit']"
  217. @click="handleSubmit(scope.row)"
  218. >提交
  219. </el-button>
  220. </el-dropdown-item> -->
  221. <!-- <el-dropdown-item v-show="scope.row.status == 5">
  222. <el-button
  223. size="mini"
  224. type="text"
  225. icon="el-icon-folder-delete"
  226. v-hasPermi="['system:RetailOrder:update']"
  227. @click="handleSubmitCancel(scope.row)"
  228. >撤销
  229. </el-button>
  230. </el-dropdown-item> -->
  231. <el-dropdown-item v-show="scope.row.status != 1">
  232. <el-button
  233. size="mini"
  234. type="text"
  235. icon="el-icon-folder-delete"
  236. @click="handleOutDetail(scope.row)"
  237. >出库明细
  238. </el-button>
  239. </el-dropdown-item>
  240. <el-dropdown-item v-show="scope.row.status == 5">
  241. <el-button
  242. size="mini"
  243. type="text"
  244. icon="el-icon-folder-delete"
  245. @click="myPrintOutBoundHandler(scope.row)"
  246. >打印出库单
  247. </el-button>
  248. </el-dropdown-item>
  249. <el-dropdown-item v-show="scope.row.status != 6">
  250. <el-button
  251. size="mini"
  252. type="text"
  253. icon="el-icon-delete"
  254. v-hasPermi="['system:RetailOrder:remove']"
  255. @click="myDeleteHandler(scope.row)"
  256. >删除
  257. </el-button>
  258. </el-dropdown-item>
  259. </el-dropdown-menu>
  260. </el-dropdown>
  261. </template>
  262. </el-table-column>
  263. </el-table>
  264. <pagination
  265. v-show="total > 0"
  266. :total="total"
  267. :page.sync="queryParams.pageNum"
  268. :limit.sync="queryParams.pageSize"
  269. @pagination="pageList"
  270. />
  271. <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
  272. <el-dialog
  273. :title="title"
  274. width="1400px"
  275. :visible.sync="open"
  276. append-to-body
  277. >
  278. <el-row :gutter="20">
  279. <el-form
  280. :model="formData"
  281. ref="formDataRef"
  282. :rules="rules"
  283. label-width="100px"
  284. :inline="true"
  285. size="normal"
  286. >
  287. <el-col :span="12">
  288. <el-form-item prop="saleNo" label="合同号:">
  289. <!-- <el-input size="small" v-model="formData.saleNo"></el-input> -->
  290. {{ formData.saleNo }}
  291. </el-form-item>
  292. </el-col>
  293. <!-- <el-col :span="12">
  294. <el-form-item prop="lotNumber" label="批号:">
  295. <el-input size="small" v-model="formData.lotNumber"></el-input>
  296. </el-form-item>
  297. </el-col> -->
  298. <el-col :span="12">
  299. <el-form-item prop="saleDate" label="日期:">
  300. <!-- <el-date-picker
  301. size="small"
  302. v-model="formData.saleDate"
  303. value-format="yyyy-MM-dd"
  304. format="yyyy-MM-dd"
  305. type="date"
  306. placeholder="选择日期"
  307. >
  308. </el-date-picker> -->
  309. {{ formData.saleDate }}
  310. </el-form-item>
  311. </el-col>
  312. <el-col :span="12">
  313. <el-form-item prop="saleCustomNo" label="客户名称:">
  314. <el-select
  315. size="small"
  316. v-model="formData.saleCustomNo"
  317. placeholder="请选择客户"
  318. clearable
  319. filterable
  320. @change="customChangeHandler"
  321. >
  322. <el-option
  323. v-for="item in customerOptions"
  324. :key="item.customNo"
  325. :label="item.customName"
  326. :value="item.customNo"
  327. >
  328. </el-option>
  329. </el-select>
  330. </el-form-item>
  331. </el-col>
  332. <el-col :span="12">
  333. <el-form-item v-if="isLeader" label="业务员:">
  334. <el-select
  335. size="small"
  336. v-model="formData.salesman"
  337. placeholder="请选择业务员"
  338. clearable
  339. filterable
  340. @change="salemanChange"
  341. >
  342. <el-option
  343. v-for="item in salesmanList"
  344. :key="item.value"
  345. :label="item.label"
  346. :value="item.value"
  347. >
  348. </el-option>
  349. </el-select>
  350. </el-form-item>
  351. <el-form-item v-else label="业务员:">
  352. <!-- <el-input
  353. v-model="formData.salesman"
  354. size="small"
  355. clearable
  356. ></el-input> -->
  357. {{ nickName }}
  358. </el-form-item>
  359. </el-col>
  360. <el-col :span="12">
  361. <el-form-item label="联系人:" size="normal">
  362. {{ formData.contactPerson }}
  363. </el-form-item>
  364. <el-form-item label="客户地址:" size="normal">
  365. {{ formData.customAddress }}
  366. </el-form-item>
  367. <el-form-item label="客户国别:" size="normal">
  368. {{ formData.customCountryType }}
  369. </el-form-item>
  370. </el-col>
  371. <el-col :span="12">
  372. <el-form-item label-width="120px" label="合计金额(大写):">
  373. <!-- <el-input
  374. v-model="formData.saleAmountInWords"
  375. size="small"
  376. clearable
  377. ></el-input> -->
  378. {{ formData.saleAmountInWords }}
  379. </el-form-item>
  380. </el-col>
  381. <el-col :span="12">
  382. <el-form-item label-width="120px" label="货车登记:">
  383. <el-input
  384. v-model="form.truckRegistration"
  385. size="small"
  386. clearable
  387. ></el-input>
  388. <!-- {{ formData.saleAmountInWords }} -->
  389. </el-form-item>
  390. </el-col>
  391. <el-col :span="12">
  392. <el-form-item prop="salePayType" label="付款方式">
  393. <!-- <el-input
  394. v-model="formData.salePayType"
  395. size="small"
  396. clearable
  397. ></el-input> -->
  398. <el-select
  399. v-model="formData.salePayType"
  400. size="small"
  401. clearable
  402. filterable
  403. >
  404. <el-option
  405. v-for="item in dict.type.payment_method"
  406. :key="item.value"
  407. :label="item.label"
  408. :value="item.value"
  409. ></el-option>
  410. </el-select>
  411. </el-form-item>
  412. </el-col>
  413. <!-- <el-col :span="12">
  414. <el-form-item label="付款方式:">
  415. <el-select
  416. v-model="formData.salePayType"
  417. size="small"
  418. clearable
  419. filterable
  420. >
  421. <el-option
  422. v-for="item in dict.type.retail_order_pay_method"
  423. :key="item.value"
  424. :label="item.label"
  425. :value="item.value"
  426. ></el-option>
  427. </el-select>
  428. 零售单
  429. </el-form-item>
  430. </el-col> -->
  431. <!-- <el-col :span="12">
  432. <el-form-item
  433. label-width="120px"
  434. prop="saleOrderEstimatedTime"
  435. label="预计下单时间:"
  436. >
  437. {{ formData.saleOrderEstimatedTime }}
  438. </el-form-item>
  439. </el-col> -->
  440. <!-- <el-col :span="12">
  441. <el-form-item label="交货日期:" size="normal" prop="deliveryDate">
  442. {{ formData.deliveryDate }}
  443. </el-form-item>
  444. </el-col> -->
  445. <!-- <el-col :span="12">
  446. <el-form-item label="交货天数:" size="normal" prop="saleLeadTime">
  447. {{ formData.saleLeadTime }}
  448. </el-form-item>
  449. </el-col> -->
  450. <el-col :span="24">
  451. <el-divider>货品明细</el-divider>
  452. </el-col>
  453. <el-table
  454. ref="productionTableRef"
  455. :data="productionTableData"
  456. border
  457. show-summary
  458. :summary-method="getSummaries"
  459. sum-text="小计"
  460. style="width: 100%"
  461. >
  462. <el-table-column prop="productName" label="品名" width="180">
  463. <template slot-scope="scope">
  464. <!-- <el-input
  465. v-model="scope.row.productName"
  466. size="small"
  467. clearable
  468. ></el-input> -->
  469. <el-form-item
  470. :prop="'productName-' + scope.$index"
  471. :name="'productName-' + scope.$index"
  472. style="margin: 0px; padding: 0px"
  473. >
  474. <!--
  475. @change="
  476. handleProductChange(scope.row.productNo, scope.row)
  477. "
  478. @blur="handleProductBlur(productNo)"
  479. -->
  480. <el-select
  481. v-model="scope.row.productName"
  482. placeholder=""
  483. filterable
  484. @change="
  485. newProductChange(scope.row.productName, scope.row)
  486. "
  487. >
  488. <el-option
  489. v-for="item in productionOptions"
  490. :key="item.productName"
  491. :label="item.productName"
  492. :value="item.productName"
  493. >
  494. <!-- <span class="discribe" style="float: left">{{
  495. item.productName
  496. }}</span>
  497. <span
  498. style="float: right; color: #8492a6; font-size: 13px"
  499. >{{ item.productSpecifications }}</span
  500. > -->
  501. </el-option>
  502. </el-select>
  503. </el-form-item>
  504. </template>
  505. </el-table-column>
  506. <el-table-column prop="productSpecifications" label="规格">
  507. <template slot-scope="scope">
  508. <el-select
  509. v-model="scope.row.productSpecifications"
  510. @change="handleSpecificationsChange(scope.row)"
  511. placeholder=""
  512. filterable
  513. >
  514. <el-option
  515. v-for="item in scope.row.specificationsList"
  516. :key="item.productSpecifications"
  517. :label="item.productSpecifications"
  518. :value="item.productSpecifications"
  519. >
  520. <span class="discribe" style="float: left">{{
  521. item.productSpecifications
  522. }}</span>
  523. <span
  524. style="float: right; color: #8492a6; font-size: 13px"
  525. >{{ item.productType }}</span
  526. >
  527. </el-option>
  528. </el-select>
  529. </template>
  530. </el-table-column>
  531. <el-table-column prop="colours" width="150" label="色号">
  532. <template slot-scope="scope">
  533. <el-form-item
  534. :prop="'colours-' + scope.$index"
  535. :name="'colours-' + scope.$index"
  536. style="margin: 0px; padding: 0px"
  537. >
  538. <el-select
  539. v-model="scope.row.colours"
  540. placeholder=""
  541. clearable
  542. filterable
  543. @change="colourNumberChangeHandler(scope.row)"
  544. >
  545. <el-option
  546. v-for="item in colourNumberOptions"
  547. :key="item.colour"
  548. :label="item.colour"
  549. :value="item.colour"
  550. >
  551. <!-- <span class="discribe" style="float: left">{{
  552. item.materieEncoding + item.materieColorNumber
  553. }}</span> -->
  554. <!-- <span
  555. style="float: right; color: #8492a6; font-size: 13px"
  556. >{{ item.materielCode }}</span
  557. > -->
  558. </el-option>
  559. </el-select>
  560. </el-form-item>
  561. </template>
  562. </el-table-column>
  563. <el-table-column prop="productType" label="类型">
  564. </el-table-column>
  565. <el-table-column prop="lotNumber" width="120" label="批号">
  566. <template slot-scope="scope">
  567. <el-input
  568. v-model="scope.row.lotNumber"
  569. placeholder=""
  570. size="small"
  571. clearable
  572. @blur="updateStorage(scope.row, 'lotNumber')"
  573. ></el-input>
  574. </template>
  575. </el-table-column>
  576. <!-- <el-table-column prop="sliceType" label="切片型号">
  577. <template slot-scope="scope">
  578. <el-form-item
  579. :prop="'sliceType-' + scope.$index"
  580. :name="'sliceType-' + scope.$index"
  581. style="margin: 0px; padding: 0px"
  582. >
  583. <el-select
  584. v-model="scope.row.sliceType"
  585. placeholder=""
  586. clearable
  587. filterable
  588. @change="sliceTypeChangeHandler(scope.row)"
  589. >
  590. <el-option
  591. v-for="item in sliceTypeOptions"
  592. :key="item.materielCode"
  593. :label="item.materielName"
  594. :value="item.materielCode"
  595. >
  596. </el-option>
  597. </el-select>
  598. </el-form-item>
  599. </template>
  600. </el-table-column> -->
  601. <el-table-column prop="productNumber" label="箱数">
  602. <template slot-scope="scope">
  603. <el-form-item
  604. :prop="'productNumber-' + scope.$index"
  605. :name="'productNumber-' + scope.$index"
  606. style="margin: 0px; padding: 0px"
  607. >
  608. <el-input
  609. v-model="scope.row.productNumber"
  610. oninput="value=value.replace(/[^0-9.]/g,'')"
  611. size="small"
  612. clearable
  613. @change="computedPrice(scope.row)"
  614. ></el-input>
  615. </el-form-item>
  616. </template>
  617. </el-table-column>
  618. <el-table-column prop="productUnitPrice" label="单价">
  619. <template slot-scope="scope">
  620. <el-form-item
  621. :prop="'productUnitPrice-' + scope.$index"
  622. :name="'productUnitPrice-' + scope.$index"
  623. style="margin: 0px; padding: 0px"
  624. >
  625. <el-input
  626. v-model="scope.row.productUnitPrice"
  627. size="small"
  628. oninput="value=value.replace(/[^0-9.]/g,'')"
  629. @change="computedPrice(scope.row)"
  630. clearable
  631. ></el-input>
  632. </el-form-item>
  633. </template>
  634. </el-table-column>
  635. <!-- <el-table-column prop="productAmounts" label="金额">-->
  636. <!-- <template slot-scope="scope">-->
  637. <!-- {{ scope.row.productAmounts }}-->
  638. <!-- </template>-->
  639. <!-- </el-table-column>-->
  640. <el-table-column prop="inventoryBoxNum" label="库存箱数">
  641. <template slot-scope="scope">
  642. {{ scope.row.inventoryBoxNum }}
  643. </template>
  644. </el-table-column>
  645. <el-table-column prop="inventoryWeight" label="库存重量/kg">
  646. <template slot-scope="scope">
  647. {{ scope.row.inventoryWeight }}
  648. </template>
  649. </el-table-column>
  650. <el-table-column prop="remark" label="备注">
  651. <template slot-scope="scope">
  652. <el-input
  653. v-model="scope.row.remark"
  654. size="small"
  655. clearable
  656. ></el-input>
  657. </template>
  658. </el-table-column>
  659. <el-table-column label="操作">
  660. <template slot-scope="scope">
  661. <el-button
  662. type="danger"
  663. size="small"
  664. @click="deleteProduct(scope.$index)"
  665. >删除</el-button
  666. >
  667. </template>
  668. </el-table-column>
  669. </el-table>
  670. <el-button
  671. class="mt5"
  672. type="primary"
  673. style="width: 100%"
  674. size="small"
  675. @click="addProduct"
  676. >添加货品</el-button
  677. >
  678. <!-- <el-col :span="12" v-show="formData.salePayType == '1'">
  679. <el-form-item prop="earnestMoney" label="定金">
  680. <el-input
  681. v-model="formData.earnestMoney"
  682. clearable
  683. size="small"
  684. />
  685. </el-form-item>
  686. </el-col> -->
  687. <el-col :span="24">
  688. <el-divider>备注</el-divider>
  689. </el-col>
  690. <el-col :span="24">
  691. <el-input
  692. type="textarea"
  693. v-model="formData.orderRemark"
  694. placeholder=""
  695. size="normal"
  696. clearable
  697. ></el-input>
  698. </el-col>
  699. <!-- <el-col :span="24">
  700. <el-divider>审计人员数据</el-divider>
  701. </el-col> -->
  702. </el-form>
  703. </el-row>
  704. <div slot="footer" class="dialog-footer">
  705. <el-button type="primary" @click="editConfirm">确 定</el-button>
  706. <el-button @click="cancel">取 消</el-button>
  707. </div>
  708. </el-dialog>
  709. <!-- 自定义弹窗 -->
  710. <el-dialog title="提交" :visible.sync="deliverShow" width="1200px">
  711. <!-- <DialogTemplate
  712. ref="dialogRef"
  713. :groupKey="groupKey"
  714. :rowobj="rowobj"
  715. :subCount="subCount"
  716. :tableCount="tableCount"
  717. :subTableName="subTableName"
  718. @addList="addListHandler"
  719. >
  720. </DialogTemplate> -->
  721. <RetailProvide ref="deliverRef"></RetailProvide>
  722. <span slot="footer" class="dialog-footer">
  723. <el-button @click="deliverShow = false">取 消</el-button>
  724. <!-- <el-button @click="btnSave">保 存</el-button> -->
  725. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  726. </span>
  727. </el-dialog>
  728. <!-- 详情弹窗 -->
  729. <el-dialog title="详情" :visible.sync="detailShow" width="1250px">
  730. <div ref="detailTable" id="detail"></div>
  731. <span slot="footer" class="dialog-footer">
  732. <el-button @click="detailShow = false">取 消</el-button>
  733. <el-button type="primary" @click="detailPrintHandler"
  734. >打 印</el-button
  735. >
  736. </span>
  737. </el-dialog>
  738. <!-- 销售出库弹窗 -->
  739. <el-dialog
  740. title="打印-销售出库单"
  741. :visible.sync="outBoundShow"
  742. width="1000px"
  743. >
  744. <OutBound ref="outBoundRef" :currentRow="currentRow"></OutBound>
  745. <span slot="footer" class="dialog-footer">
  746. <el-button @click="outBoundShow = false">取 消</el-button>
  747. <el-button type="primary" @click="outBoundPrintHandler">
  748. 打印</el-button
  749. >
  750. </span>
  751. </el-dialog>
  752. <!-- 出库详情 -->
  753. <el-dialog title="出库明细" :visible.sync="outStockShow" width="1200px">
  754. <OutStock ref="outStockRef"></OutStock>
  755. <span slot="footer" class="dialog-footer">
  756. <el-button @click="outStockShow = false">关 闭</el-button>
  757. <!-- <el-button @click="btnSave">保 存</el-button> -->
  758. <!-- <el-button type="primary" @click="btnComfirm">确 定</el-button> -->
  759. </span>
  760. </el-dialog>
  761. <div id="printDom"></div>
  762. </div>
  763. </el-card>
  764. </template>
  765. <script>
  766. import {
  767. delTableData,
  768. dragTableInfo,
  769. listTable,
  770. unionListTableData,
  771. getInfoBySqlKey,
  772. btnCommonApi,
  773. addTableData,
  774. batchEdit,
  775. getStatisticList,
  776. getTableList1,
  777. checkOrderNo,
  778. delOrder,
  779. productInvoiceInfo,
  780. addProductInvoice,
  781. updateProductInvoice,
  782. queryMaterielList,
  783. getSaleOrderProductionListDistinct,
  784. getProductSpecificationsByProductName,
  785. productColourList,
  786. } from "@/api/tablelist/commonTable";
  787. import {
  788. saleOrderList,
  789. getRoleUser,
  790. addRetailOrder,
  791. getRetailOrderInfo,
  792. editRetailOrder,
  793. retailProductInvoiceInfo,
  794. submitRetailOrder,
  795. cancelRetailOrder,
  796. deleRetailOrder,
  797. submitProductInvoice,
  798. getProductInventory,
  799. updateOrder,
  800. } from "@/api/system/retailMange.js";
  801. import { listData } from "@/api/system/tenant/data";
  802. import { getToken } from "@/utils/auth";
  803. import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
  804. import { camelCase, toUnderline } from "@/utils";
  805. import { inputDisableComplete } from "@/utils/other";
  806. import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
  807. import { checkRole } from "@/utils/permission";
  808. import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
  809. import {
  810. queryDropDownBoxData,
  811. getSaleOrderProductionList,
  812. } from "@/api/dragform/form";
  813. import { v4 as uuidv4 } from "uuid";
  814. import { mapState } from "vuex";
  815. import moment from "moment";
  816. import Deliver from "@/views/orderMange/components/dialogForm/Deliver.vue";
  817. import RetailProvide from "@/views/orderMange/components/dialogForm/RetailProvide.vue";
  818. import OutStock from "@/views/orderMange/components/dialogForm/OutStock.vue";
  819. import OutBound from "@/views/orderMange/components/dialogForm/OutBound.vue";
  820. import outBoundPrint from "@/utils/print/outBoundPrint";
  821. import { listCustomer } from "@/api/system/customer";
  822. import { numToCapital } from "@/utils/other";
  823. export default {
  824. name: "retailMange",
  825. dicts: [
  826. "payment_method",
  827. "direction_of_twist",
  828. "retail_order_pay_method",
  829. "sales_order_status",
  830. ],
  831. components: {
  832. Queryfrom,
  833. Menu,
  834. DialogTemplate,
  835. Deliver,
  836. OutBound,
  837. RetailProvide,
  838. OutStock,
  839. },
  840. data() {
  841. return {
  842. // 提交 表单数据 start
  843. form: {
  844. noticeNumber: "", //通知单号
  845. noticeDate: "", //通知日期
  846. salesman: "", //销售员
  847. customerId: "", //客户编号
  848. drawer: "", //开票员
  849. dispatchNoteRemark: "", //发货单备注
  850. billingType: "", //开票类型
  851. truckRegistration: "", //货车登记
  852. documentType: "", //单据类型
  853. sellingUnit: "", //售货单位
  854. auditOpinion: "", //审核意见
  855. inventoryBoxNum: "", //库存箱数
  856. inventoryWeight: "", //库存重量
  857. batchNumberType: 1, //批次类型
  858. computeType: 1, //计算方式
  859. },
  860. // 提交 表单数据 end
  861. outStockShow: false, //出库详情弹窗
  862. totalMoney: "", //合计金额 小写
  863. createById: "", //创建者id
  864. salesmanList: [], //销售员列表
  865. isLeader: false, //当前登录用户是否为领导
  866. selection: [], //勾选的数据
  867. // 出库单 start
  868. outBoundShow: false,
  869. // 出库单 end
  870. // 发货 start
  871. deliverShow: false,
  872. // 发货 end
  873. // 出库单 start
  874. // 出库单 end
  875. myDelIds: [], //新增接口 删除的id
  876. // 详情弹窗数据
  877. detailShow: false,
  878. printDomData: "",
  879. // k-form-build组件渲染弹窗
  880. kOpen: false,
  881. // 新的自定义数据 start
  882. orderType: 0, //新的条件查询参数
  883. productIds: [], //货品Ids
  884. isEdit: false,
  885. formData: {
  886. //订单表数据
  887. saleNo: "", //合同号
  888. saleCustomNo: "", //客户编号
  889. saleDate: "", //销售单日期
  890. saleOrderEstimatedTime: "", //预计下单时间
  891. saleLeadTime: "1", //交货周期
  892. deliveryDate: "", //交货日期
  893. saleAmounts: "", //合计金额 小写
  894. saleAmountInWords: "", //合计金额 大写
  895. salePayType: "2", //支付方式
  896. earnestMoney: "", //定金
  897. salesman: "", //业务员
  898. saleLeader: "", //业务主管
  899. finance: "", //财务部
  900. production: "", //生产部
  901. saleApprover: "", //批准人
  902. customAddress: "", //客户地址
  903. customCountryType: "", //国家类型
  904. contactPerson: "", //联系人
  905. // 货品明细表数据
  906. lotNumber: "", //批号
  907. productNo: "", //货品号
  908. productName: "", //货品名称
  909. productNumber: "", //销售数量
  910. productWeight: "", //销售重量kg
  911. productUnitPrice: "", //单价
  912. productAmounts: "", //金额
  913. sliceType: "", //切片类型
  914. sliceTypeLabel: "",
  915. colourNumberLabel: "",
  916. colours: "", //色号
  917. remark: "", //备注
  918. // 工艺表
  919. orderRemark: "",
  920. },
  921. sliceTypeOptions: [], //切片型号选项
  922. colourNumberOptions: [], //色号选项
  923. allProductionOptions: [], //所有产品选项
  924. productionOptions: [],
  925. customerOptions: [],
  926. productionTableData: [
  927. // {
  928. // productNo: "", //货品名称
  929. // productNumber: 2, //销售数量
  930. // productWeight: 1, //销售重量kg
  931. // productUnitPrice: 20, //单价
  932. // productAmounts: 20, //金额
  933. // remark: "", //备注
  934. // },
  935. ],
  936. rules: {
  937. saleNo: [
  938. {
  939. required: true,
  940. message: "请输入合同号",
  941. trigger: "blur",
  942. },
  943. // {
  944. // validator: this.validateOrderNo,
  945. // trigger: "blur",
  946. // },
  947. ],
  948. saleDate: [
  949. {
  950. required: true,
  951. message: "请选择日期",
  952. trigger: "change",
  953. },
  954. ],
  955. // lotNumber: [
  956. // {
  957. // required: true,
  958. // message: "请输入批号",
  959. // trigger: "blur",
  960. // },
  961. // ],
  962. saleCustomNo: [
  963. {
  964. required: true,
  965. message: "请选择客户",
  966. trigger: "change",
  967. },
  968. ],
  969. salePayType: [
  970. {
  971. required: true,
  972. message: "请选择付款方式",
  973. trigger: "change",
  974. },
  975. ],
  976. saleOrderEstimatedTime: [
  977. {
  978. required: true,
  979. message: "请选择预计下单时间",
  980. trigger: "change",
  981. },
  982. ],
  983. saleLeadTime: [
  984. {
  985. required: true,
  986. message: "请输入交货天数",
  987. trigger: "blur",
  988. },
  989. ],
  990. // earnestMoney: [
  991. // {
  992. // validator: this.validateEarnestMoney,
  993. // trigger: "blur",
  994. // },
  995. // ],
  996. },
  997. // end
  998. // 绑定按钮dialog
  999. btnDialogVisible: false,
  1000. // 绑定修改dialog
  1001. groupKey: "",
  1002. // 遮罩层
  1003. loading: true,
  1004. // 选中数组
  1005. ids: [],
  1006. // 非单个禁用
  1007. single: true,
  1008. // 非多个禁用
  1009. multiple: true,
  1010. // 显示统计
  1011. showCount: true,
  1012. // 显示搜索条件
  1013. showSearch: true,
  1014. // 总条数
  1015. total: 0,
  1016. // 用户表格数据
  1017. tableList: [],
  1018. // 弹出层标题
  1019. title: "",
  1020. // 日期范围
  1021. dateRange: [],
  1022. // cru 弹窗
  1023. open: false,
  1024. // excel共通导入数据
  1025. upload: {
  1026. // 是否显示弹出层
  1027. open: false,
  1028. // 弹出层标题(
  1029. title: "",
  1030. // 是否禁用上传
  1031. isUploading: false,
  1032. // 是否更新已经存在的数据
  1033. updateSupport: 0,
  1034. // 设置上传的请求头部
  1035. headers: { Authorization: "Bearer " + getToken() },
  1036. // 上传的地址
  1037. url: process.env.VUE_APP_BASE_API1 + "common/uploadData",
  1038. },
  1039. // 排序方式 默认降序
  1040. sortOrder: true,
  1041. // 共通查询参数接受子组件的参数
  1042. queryParams: {
  1043. saleOrderTechnologyNo: "retailOrder",
  1044. pageNum: 1, // 第几页
  1045. pageSize: 10, // 每页大小
  1046. orderByColumn: "", // 根据某列排序
  1047. isAsc: "", // desc(降序)或 asc(升序)
  1048. saleOrderOrderType: "",
  1049. status: 100, //订单是否已完成/为完成
  1050. // 基本查询参数
  1051. basicMap: {
  1052. tableName: "drag_form",
  1053. },
  1054. // 当前表字段筛选参数
  1055. queryMap: {
  1056. queryCriteriaValue: "",
  1057. },
  1058. },
  1059. // 列信息
  1060. columns: {},
  1061. // 当前模版信息
  1062. templateInfo: {},
  1063. // 查询条件
  1064. queryFromWhere: {},
  1065. // 当前table唯一标识
  1066. tableKey: null,
  1067. // 当前表名称
  1068. tableName: null,
  1069. //存放html代码块
  1070. iframeUrl: "",
  1071. //存放表单渲染数据
  1072. jsonData: {},
  1073. // 回显表格数据,
  1074. defaultValue: {},
  1075. // 统计card
  1076. statisticList: [],
  1077. // 样式表
  1078. styleList: [],
  1079. // 字典样式对象
  1080. dictStyleObj: {},
  1081. // 操作列 按钮数据
  1082. excuteBtnArr: [],
  1083. // 下拉框动态数据
  1084. dynamicData: {},
  1085. // 当前点击按钮的数据
  1086. currentBtnData: {},
  1087. // 修改选中行
  1088. rowobj: {},
  1089. // 该行的统计信息
  1090. subCount: [],
  1091. tableCount: [],
  1092. // 弹窗新增数据
  1093. addLists: [],
  1094. subTableName: "",
  1095. // 当前点击行的数据
  1096. currentRow: {},
  1097. };
  1098. },
  1099. created() {
  1100. // 得到当前展示的table的唯一标识
  1101. this.tableKey = this.$route.query.tableKey;
  1102. this.getList(this.queryParams);
  1103. },
  1104. watch: {
  1105. totalMoney: {
  1106. handler(newVal, oldVal) {
  1107. if (isNaN(Number(newVal))) {
  1108. this.formData.saleAmountInWords = "零";
  1109. } else {
  1110. const ntc = new numToCapital();
  1111. this.formData.saleAmountInWords = ntc.uppercase(newVal);
  1112. }
  1113. },
  1114. deep: true,
  1115. immediate: true,
  1116. },
  1117. },
  1118. async mounted() {
  1119. await this.getDropDownData();
  1120. },
  1121. computed: {
  1122. isShowExcuteCol() {
  1123. return !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
  1124. },
  1125. ...mapState({
  1126. nickName: (state) => state.user.nickName,
  1127. userInfo: (state) => state.user,
  1128. username: (state) => state.user.name,
  1129. }),
  1130. },
  1131. methods: {
  1132. orderStartChange(status) {
  1133. this.getList(false, status);
  1134. },
  1135. // 零售订单完成回调
  1136. async handleComplate(row) {
  1137. console.log(row);
  1138. let payload = {
  1139. id: row.id,
  1140. status: 6,
  1141. saleNo: row.saleNo,
  1142. completionTime: new Date(),
  1143. };
  1144. let res = await updateOrder(payload);
  1145. if (res.code == 200) {
  1146. this.$message({
  1147. type: "success",
  1148. message: "订单已完成",
  1149. });
  1150. this.getList();
  1151. } else {
  1152. this.$message({
  1153. type: "error",
  1154. message: "订单已完成失败,请稍后再试",
  1155. });
  1156. console.log(res);
  1157. }
  1158. },
  1159. // 更新库存箱数和重量
  1160. async updateStorage(row) {
  1161. let {
  1162. productNo,
  1163. productType,
  1164. lotNumber,
  1165. productName,
  1166. productSpecifications,
  1167. colours,
  1168. specificationsList,
  1169. } = row;
  1170. let productColour = "";
  1171. let targetColor = this.colourNumberOptions.find((item) => {
  1172. return item.colour == colours;
  1173. });
  1174. let productId = "";
  1175. if (specificationsList && specificationsList.length > 0) {
  1176. let targetItem = specificationsList.find(
  1177. (item) => item.productSpecifications == productSpecifications
  1178. );
  1179. productId = targetItem.id;
  1180. }
  1181. if (targetColor) {
  1182. productColour =
  1183. targetColor.materieEncoding + "" + targetColor.materieColorNumber;
  1184. }
  1185. productColour =colours;
  1186. let payload = {
  1187. productId,
  1188. productType,
  1189. lotNum: lotNumber,
  1190. productName,
  1191. productSpecifications,
  1192. productColour,
  1193. };
  1194. if (
  1195. !lotNumber &&
  1196. !productId &&
  1197. !productType &&
  1198. !productName &&
  1199. !productSpecifications &&
  1200. !productColour
  1201. )
  1202. return;
  1203. let res = await getProductInventory(payload);
  1204. if ((res.code = 200)) {
  1205. console.log(res);
  1206. row.inventoryWeight = res.data.inventoryWeight || 0;
  1207. row.inventoryBoxNum = res.data.inventoryBoxNum || 0;
  1208. } else {
  1209. console.log(res);
  1210. }
  1211. },
  1212. // 规格变化回调
  1213. handleSpecificationsChange(row) {
  1214. let { productSpecifications, specificationsList } = row;
  1215. if (productSpecifications) {
  1216. let targetItem = specificationsList.find(
  1217. (item) => item.productSpecifications == productSpecifications
  1218. );
  1219. console.log(targetItem);
  1220. row.productNo = targetItem?.productNo;
  1221. row.productType = targetItem?.productType;
  1222. } else {
  1223. row.productNo = "";
  1224. row.productType = "";
  1225. }
  1226. this.updateStorage(row);
  1227. },
  1228. // 新的产品改变回调
  1229. async newProductChange(productName, row) {
  1230. // 发请求获取对应的规格数据
  1231. if (!productName) {
  1232. row.specificationsList = [];
  1233. (row.productNo = ""), (row.productType = "");
  1234. row.productSpecifications = "";
  1235. return;
  1236. }
  1237. // let targetItem = this.productionOptions.find(
  1238. // (item) => item.productNo == productNo
  1239. // );
  1240. // row.productName = targetItem?.productName;
  1241. // row.productType = targetItem?.productType;
  1242. // 获取规格数据
  1243. let res = await getProductSpecificationsByProductName({
  1244. productName: productName,
  1245. });
  1246. if (res.code == 200) {
  1247. row.specificationsList = res.data;
  1248. console.log(row.specificationsList);
  1249. let defaultItem = row.specificationsList.find(
  1250. (item) => item.isDefaultSpecifications
  1251. );
  1252. if (defaultItem) {
  1253. row.productSpecifications = defaultItem.productSpecifications;
  1254. row.productNo = defaultItem.productNo;
  1255. row.productType = defaultItem.productType;
  1256. } else {
  1257. row.productSpecifications =
  1258. row.specificationsList[0]?.productSpecifications || "";
  1259. row.productNo = row.specificationsList[0]?.productNo || "";
  1260. row.productType = row.specificationsList[0]?.productType || "";
  1261. }
  1262. } else {
  1263. row.specificationsList = [];
  1264. }
  1265. this.updateStorage(row);
  1266. },
  1267. // 出库单回调
  1268. async myPrintOutBoundHandler(row) {
  1269. console.log("row", row);
  1270. this.currentRow = row;
  1271. this.outBoundShow = true;
  1272. this.$nextTick(() => {
  1273. this.$refs.outBoundRef.getTableData(row);
  1274. });
  1275. },
  1276. // 出库详情回调
  1277. handleOutDetail(row) {
  1278. this.outStockShow = true;
  1279. this.$nextTick(() => {
  1280. this.$refs.outStockRef.getOutStockDetail(row);
  1281. });
  1282. },
  1283. // 业务员改变回调
  1284. salemanChange(val) {
  1285. if (!val) {
  1286. this.createById = "";
  1287. return;
  1288. } else {
  1289. this.createById = this.salesmanList.find(
  1290. (item) => item.value == val
  1291. ).id;
  1292. }
  1293. },
  1294. // 生成合同号
  1295. getSaleNo() {
  1296. let timeStr = moment().format("YYYYMMDD");
  1297. for (var i = 0; i < 5; i++) {
  1298. timeStr += parseInt(Math.random() * 10);
  1299. }
  1300. return timeStr;
  1301. },
  1302. // 自定义筛选方法
  1303. mySelectFilter(value, row) {
  1304. console.log(value);
  1305. // row.productNo = value;
  1306. if (value) {
  1307. let target = [];
  1308. // 在全部列表中查找
  1309. target = this.allProductionOptions.filter((item) =>
  1310. item.productName.includes(value)
  1311. );
  1312. console.log(target);
  1313. if (target.length) {
  1314. this.productionOptions = target;
  1315. return true;
  1316. } else {
  1317. return false;
  1318. }
  1319. } else {
  1320. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1321. }
  1322. },
  1323. // // 出库单回调
  1324. // async myPrintOutBoundHandler(row, data) {
  1325. // console.log("row", row);
  1326. // this.currentRow = row;
  1327. // this.outBoundShow = true;
  1328. // this.$nextTick(() => {
  1329. // this.$refs.outBoundRef.getTableData(row);
  1330. // });
  1331. // },
  1332. // 出库单打印回调
  1333. async outBoundPrintHandler() {
  1334. let res = await this.$refs.outBoundRef.getPrintData();
  1335. console.log(res);
  1336. if (res.flag) {
  1337. res.data.form.printUser = this.nickName;
  1338. outBoundPrint(res.data, "printDom", true);
  1339. }
  1340. },
  1341. // 产品名失焦
  1342. handleProductBlur(productNo) {
  1343. console.log("blur", productNo);
  1344. // if (!productNo) {
  1345. // this.productionOptions = this.allProductionOptions.slice(0, 500);
  1346. // }
  1347. },
  1348. // 产品名称改变
  1349. handleProductChange(productNo, row) {
  1350. if (!productNo) {
  1351. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1352. return;
  1353. }
  1354. row.productName = this.productionOptions.find(
  1355. (item) => item.productNo == productNo
  1356. )?.productName;
  1357. row.productType = this.productionOptions.find(
  1358. (item) => item.productNo == productNo
  1359. )?.productType;
  1360. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1361. },
  1362. // 重置审计表单数据
  1363. resetFormData() {
  1364. Object.assign(this.formData, {
  1365. //订单表数据
  1366. saleNo: this.getSaleNo(), //合同号
  1367. saleCustomNo: "", //客户编号
  1368. saleDate: moment(new Date()).format("YYYY-MM-DD"), //销售单日期
  1369. saleOrderEstimatedTime: moment(new Date()).format("YYYY-MM-DD"), //预计下单时间
  1370. saleLeadTime: "1", //交货周期
  1371. deliveryDate: moment(new Date()).format("YYYY-MM-DD"),
  1372. saleAmounts: "", //合计金额 小写
  1373. saleAmountInWords: "", //合计金额 大写
  1374. salePayType: "2", //支付方式
  1375. earnestMoney: "",
  1376. salesman: "", //业务员
  1377. saleLeader: "", //业务主管
  1378. finance: "", //财务部
  1379. production: "", //生产部
  1380. saleApprover: "", //批准人
  1381. customAddress: "", //客户地址
  1382. customCountryType: "", //国家类型
  1383. contactPerson: "", //联系人
  1384. // 货品明细表数据
  1385. lotNumber: "", //批号
  1386. productNo: "", //货品号
  1387. productName: "", //货品名称
  1388. productNumber: "", //销售数量
  1389. productWeight: "", //销售重量kg
  1390. productUnitPrice: "", //单价
  1391. productAmounts: "", //金额
  1392. sliceType: "", //切片类型
  1393. sliceTypeLabel: "",
  1394. colourNumberLabel: "",
  1395. colours: "", //色号
  1396. remark: "", //备注
  1397. // 工艺表
  1398. craftGrid: "", //网络
  1399. craftOil: "", //油剂
  1400. craftPackage: "", //卷装
  1401. craftColorFastness: "", //色牢度
  1402. directionOfTwist: "",
  1403. craftOther: "", //其它工艺要求
  1404. craftMark: "", //包装/贴唛
  1405. shippingMethod: "", //运输方式
  1406. });
  1407. this.productionTableData = [];
  1408. },
  1409. // 自定义的小计计算方法
  1410. getSummaries(param) {
  1411. const { columns, data } = param;
  1412. console.log(columns, data);
  1413. const sums = [];
  1414. columns.forEach((column, index) => {
  1415. if (index === 0) {
  1416. sums[index] = "小计";
  1417. return;
  1418. }
  1419. const values = data.map((item) => Number(item[column.property]));
  1420. if (
  1421. index === 1 ||
  1422. index === 2 ||
  1423. index === 3 ||
  1424. index === 4 ||
  1425. index === 7 ||
  1426. index === 8 ||
  1427. index === 9 ||
  1428. index === 10 ||
  1429. index === 11
  1430. ) {
  1431. sums[index] = "";
  1432. } else if (!values.every((value) => isNaN(value))) {
  1433. sums[index] = values.reduce((prev, curr) => {
  1434. const value = Number(curr);
  1435. if (!isNaN(value)) {
  1436. return prev + curr;
  1437. } else {
  1438. return prev;
  1439. }
  1440. }, 0);
  1441. if (index == 7 || index == 6) {
  1442. sums[index] = sums[index]?.toFixed(2);
  1443. }
  1444. console.log(sums[index], index);
  1445. if (index == 7) {
  1446. this.totalMoney = sums[index];
  1447. }
  1448. } else {
  1449. sums[index] = "N/A";
  1450. }
  1451. });
  1452. return sums;
  1453. },
  1454. // 货品表格数据删除回调
  1455. deleteProduct(index) {
  1456. this.productionTableData.splice(index, 1);
  1457. this.initTableValidate();
  1458. },
  1459. // 货品表格数据新增回调
  1460. addProduct() {
  1461. this.productionTableData.push({
  1462. saleProductNo: uuidv4(),
  1463. productNo: "", //货品编号
  1464. productType: "", //类型
  1465. lotNumber: "", //批号
  1466. productName: "", //货品名称
  1467. productNumber: 0, //销售数量
  1468. productWeight: "", //销售重量kg
  1469. productUnitPrice: 0, //单价
  1470. productAmounts: "", //金额
  1471. sliceType: "022", //切片类型 初始为 切片
  1472. sliceTypeLabel: "",
  1473. colourNumberLabel: "",
  1474. colours: "", //色号
  1475. remark: "", //备注
  1476. specificationsList: [],
  1477. productSpecifications: "", //型号
  1478. inventoryBoxNum: "", //库存箱数
  1479. inventoryWeight: "", //库存重量
  1480. });
  1481. // 添加校验规则
  1482. this.initTableValidate();
  1483. },
  1484. // 自定义校验规则
  1485. validateTableField(rule, value, callback) {
  1486. let { message, field } = rule;
  1487. let index = field.split("-")[1],
  1488. fieldName = field.split("-")[0];
  1489. console.log(
  1490. index,
  1491. fieldName,
  1492. this.productionTableData[Number(index)][fieldName]
  1493. );
  1494. console.log(this.productionTableData);
  1495. if (
  1496. !this.productionTableData[Number(index)][fieldName] &&
  1497. this.productionTableData[Number(index)][fieldName] !== 0 &&
  1498. this.productionTableData[Number(index)][fieldName] !== "0"
  1499. ) {
  1500. callback(new Error(message));
  1501. } else {
  1502. callback();
  1503. }
  1504. },
  1505. // 初始化校验规则
  1506. initTableValidate() {
  1507. let length = this.productionTableData.length;
  1508. for (let i = 0; i < length; i++) {
  1509. this.rules["productNo-" + i] = [
  1510. {
  1511. // required: true,
  1512. message: "请选择货品",
  1513. trigger: "change",
  1514. validator: this.validateTableField,
  1515. },
  1516. ];
  1517. this.rules["productNumber-" + i] = [
  1518. {
  1519. // required: true,
  1520. message: "请输入数量",
  1521. trigger: "blur",
  1522. validator: this.validateTableField,
  1523. },
  1524. ];
  1525. this.rules["productUnitPrice-" + i] = [
  1526. {
  1527. // required: true,
  1528. message: "请输入单价",
  1529. trigger: "blur",
  1530. validator: this.validateTableField,
  1531. },
  1532. ];
  1533. this.rules["sliceType-" + i] = [
  1534. {
  1535. // required: true,
  1536. message: "请选择切片类型",
  1537. trigger: "change",
  1538. validator: this.validateTableField,
  1539. },
  1540. ];
  1541. this.rules["colours-" + i] = [
  1542. {
  1543. // required: true,
  1544. message: "请选择色号",
  1545. trigger: "change",
  1546. validator: this.validateTableField,
  1547. },
  1548. ];
  1549. }
  1550. console.log(this.rules);
  1551. },
  1552. // 客户名称改变回调
  1553. customChangeHandler(val) {
  1554. // if (!val) return;
  1555. let customData = this.customerOptions.find(
  1556. (item) => item.customNo == val
  1557. );
  1558. this.formData.customAddress = customData?.customAddress || "无";
  1559. this.formData.customCountryType = customData?.customCountryType || "无";
  1560. this.formData.contactPerson = customData?.contactPerson || "无";
  1561. },
  1562. // 获取销售员角色列表
  1563. async getRoleUser() {
  1564. try {
  1565. let res = await getRoleUser("salesman");
  1566. if (res.code == 200) {
  1567. this.salesmanList = res.data.map((item) => {
  1568. return {
  1569. label: item.nickName,
  1570. value: item.nickName,
  1571. id: item.userId,
  1572. };
  1573. });
  1574. } else {
  1575. this.$message.error("获取销售员角色列表失败");
  1576. }
  1577. } catch (error) {
  1578. console.log(error);
  1579. }
  1580. },
  1581. //审计新增
  1582. async addHandler() {
  1583. this.isEdit = false;
  1584. await this.getDropDownData();
  1585. // 判断是否是销售员
  1586. console.log(this.userInfo);
  1587. this.isLeader = !this.userInfo.roles.includes("salesman");
  1588. if (!this.isLeader) {
  1589. this.createById = this.userInfo.userId;
  1590. }
  1591. await this.getRoleUser();
  1592. this.resetFormData();
  1593. this.title = "新增零售单";
  1594. this.open = true;
  1595. this.$nextTick(() => {
  1596. this.$refs.formDataRef.resetFields();
  1597. this.formData.orderRemark = "";
  1598. // this.$refs["formDataRef"].clearValidate();
  1599. });
  1600. },
  1601. // 获取下拉框数据
  1602. async getDropDownData() {
  1603. try {
  1604. // let payLoad = [
  1605. // {
  1606. // basicMap: {
  1607. // tableName: "production",
  1608. // },
  1609. // },
  1610. // {
  1611. // basicMap: {
  1612. // tableName: "customer",
  1613. // },
  1614. // },
  1615. // ];
  1616. // let res = await queryDropDownBoxData(payLoad);
  1617. // 新的获取客户选项数据的接口
  1618. let res = await listCustomer({ isEnablePaging: false });
  1619. if (res.code == 200) {
  1620. // let { customer } = res.data.resultMap;
  1621. // this.allProductionOptions = production || [];
  1622. // this.productionOptions =
  1623. // this.allProductionOptions.slice(0, 100) || [];
  1624. this.customerOptions = res.rows || [];
  1625. } else {
  1626. throw Error("获取下拉框数据失败");
  1627. }
  1628. let proRes = await getSaleOrderProductionListDistinct();
  1629. if (proRes.code == 200) {
  1630. // let { production, customer } = proRes.data.resultMap;
  1631. this.productionOptions = proRes.data;
  1632. } else {
  1633. throw Error("获取下拉框数据失败");
  1634. }
  1635. let allProRes = await getSaleOrderProductionList();
  1636. if (allProRes.code == 200) {
  1637. this.allProductionOptions = allProRes.data || [];
  1638. } else {
  1639. console.log(allProRes);
  1640. }
  1641. } catch (error) {
  1642. console.log(error);
  1643. }
  1644. // 色号数据
  1645. try {
  1646. let payLoad = [
  1647. {
  1648. basicMap: {
  1649. tableName: "materiel",
  1650. },
  1651. conditionMap: {
  1652. materiel_species: ["1"],
  1653. },
  1654. },
  1655. ];
  1656. // let res = await queryDropDownBoxData(payLoad);
  1657. // let res = await queryMaterielList();
  1658. let res = await productColourList({ isEnablePaging: false });
  1659. if (res.code == 200) {
  1660. // let { materiel } = res.data;
  1661. this.colourNumberOptions = res.rows || [];
  1662. } else {
  1663. throw Error("获取下拉框数据失败");
  1664. }
  1665. } catch (error) {
  1666. console.log(error);
  1667. }
  1668. // 切片型号
  1669. try {
  1670. let payLoad = [
  1671. {
  1672. basicMap: {
  1673. tableName: "materiel",
  1674. },
  1675. conditionMap: {
  1676. materiel_species: ["6"],
  1677. },
  1678. },
  1679. ];
  1680. let res = await queryDropDownBoxData(payLoad);
  1681. if (res.code == 200) {
  1682. console.log(res.data.resultMap);
  1683. let { materiel } = res.data.resultMap;
  1684. this.sliceTypeOptions = materiel || [];
  1685. } else {
  1686. throw Error("获取下拉框数据失败");
  1687. }
  1688. } catch (error) {
  1689. console.log(error);
  1690. }
  1691. },
  1692. //
  1693. // 获取row-key
  1694. getRowKey(row) {
  1695. return row[
  1696. camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
  1697. ];
  1698. },
  1699. /** 查询列表 */
  1700. async getList() {
  1701. this.loading = true;
  1702. try {
  1703. let res = await saleOrderList(this.queryParams);
  1704. console.log(res);
  1705. if (res.code == 200) {
  1706. this.tableList = res.rows;
  1707. console.log(this.dict.type.sales_order_status);
  1708. this.tableList.forEach((item) => {
  1709. item.listClass = this.dict.type.sales_order_status.find(
  1710. (i) => i.value == item.status
  1711. ).raw.listClass;
  1712. });
  1713. this.total = res.total;
  1714. } else {
  1715. this.$message.error(res.msg);
  1716. }
  1717. this.loading = false;
  1718. } catch (error) {
  1719. console.log(error);
  1720. this.loading = false;
  1721. }
  1722. },
  1723. // 校验定金
  1724. validateEarnestMoney(rule, value, callback) {
  1725. console.log(value);
  1726. if (this.formData.salePayType == "1") {
  1727. if (value == "" || value == null || value == undefined) {
  1728. callback(new Error("请输入定金金额"));
  1729. } else {
  1730. callback();
  1731. }
  1732. } else {
  1733. callback();
  1734. }
  1735. },
  1736. // 校验订单号是否有效
  1737. async validateOrderNo(rule, value, callback) {
  1738. console.log(value);
  1739. // let saleNo = this.formData.orderNo;
  1740. // 检验订单号合法
  1741. let checkNoPayload = {
  1742. saleNo: value,
  1743. };
  1744. if (this.isEdit) {
  1745. checkNoPayload.id = this.formData.id;
  1746. }
  1747. let result = await checkOrderNo(checkNoPayload);
  1748. if (result.code == 200) {
  1749. if (result.data) {
  1750. callback();
  1751. } else {
  1752. callback(new Error("合同号已存在"));
  1753. }
  1754. } else {
  1755. callback(new Error("校验失败,请稍后再试"));
  1756. }
  1757. },
  1758. // 校验表格数据
  1759. validateTableData() {
  1760. if (this.productionTableData.length == 0) {
  1761. return {
  1762. res: false,
  1763. msg: "请添加货品明细",
  1764. };
  1765. }
  1766. let res = this.productionTableData.every((item) => {
  1767. return (
  1768. item.productNo &&
  1769. item.productNumber &&
  1770. item.productUnitPrice &&
  1771. item.productAmounts &&
  1772. item.sliceType &&
  1773. item.colours
  1774. );
  1775. });
  1776. if (!res) {
  1777. return {
  1778. res: false,
  1779. msg: "请填写完整货品明细",
  1780. };
  1781. }
  1782. return {
  1783. res: true,
  1784. msg: "",
  1785. };
  1786. },
  1787. // 审计 提交编辑结果按钮回调
  1788. async editConfirm() {
  1789. // let tableValidate = this.validateTableData();
  1790. // if (!tableValidate.res) {
  1791. // this.$message.warning(tableValidate.msg);
  1792. // }
  1793. this.$refs.formDataRef.validate(async (valid) => {
  1794. if (valid) {
  1795. console.log(valid);
  1796. let {
  1797. id,
  1798. //订单表数据
  1799. saleNo,
  1800. saleCustomNo,
  1801. saleDate,
  1802. saleOrderEstimatedTime,
  1803. saleLeadTime,
  1804. deliveryDate,
  1805. saleAmounts,
  1806. saleAmountInWords,
  1807. salePayType,
  1808. salesman,
  1809. customAddress,
  1810. customCountryType, //国家类型
  1811. contactPerson, //联系人
  1812. // 工艺表数据
  1813. orderRemark,
  1814. } = this.formData;
  1815. let payload = {
  1816. createById: this.createById,
  1817. saleOrderTechnologyNo: "retailOrder",
  1818. saleNo,
  1819. saleCustomNo,
  1820. saleDate,
  1821. saleOrderEstimatedTime,
  1822. saleLeadTime,
  1823. deliveryDate,
  1824. saleAmounts,
  1825. saleAmountInWords,
  1826. salePayType,
  1827. customAddress, //客户地址
  1828. customCountryType, //国家类型
  1829. contactPerson, //联系人
  1830. remark: orderRemark,
  1831. salesman: this.isLeader ? salesman : this.nickName,
  1832. status: 1,
  1833. };
  1834. payload.saleProductsList = this.productionTableData;
  1835. // 准备 提交 数据 start
  1836. this.form.saleCustomNo = saleCustomNo;
  1837. this.form.salesman = salesman;
  1838. this.form.noticeDate = moment(new Date()).format("YYYY-MM-DD");
  1839. this.form.drawer = this.username;
  1840. this.form.documentType = "1";
  1841. this.form.billingType = "1";
  1842. this.form.saleOrderNo = saleNo;
  1843. this.form.dispatchNoteRemark = orderRemark;
  1844. this.form.customerId = this.customerOptions.find(
  1845. (item) => item.customNo == saleCustomNo
  1846. )?.id;
  1847. // 准备 提交 数据 end
  1848. if (this.isEdit) {
  1849. payload.id = id;
  1850. payload.truckRegistration = this.form.truckRegistration;
  1851. delete payload.status;
  1852. let res = await editRetailOrder(payload);
  1853. if (res.code === 200) {
  1854. this.$message.success("修改成功");
  1855. this.open = false;
  1856. this.getList();
  1857. } else {
  1858. this.$message.error("修改失败");
  1859. }
  1860. } else {
  1861. //新增
  1862. payload.orderType = 1;
  1863. let res = await addRetailOrder(payload);
  1864. if (res.code == 200) {
  1865. // 准备新增时 提交 数据 start
  1866. this.form.noticeNumber = this.getOrderNo();
  1867. this.form.status = 5;
  1868. this.form.id = res.data;
  1869. // 提交 新增接口
  1870. let result = await submitRetailOrder({
  1871. ...this.form,
  1872. saleProductInfoList: this.productionTableData,
  1873. });
  1874. if (result.code == 200) {
  1875. this.$message.success("提交成功");
  1876. this.open = false;
  1877. this.getList();
  1878. } else {
  1879. this.$message.error("提交失败");
  1880. }
  1881. // 准备新增时 提交 数据 end
  1882. } else {
  1883. this.$message.error("添加失败");
  1884. }
  1885. }
  1886. // Object.keys(saleValue).map((k) => {
  1887. // saleData.commMap[k] = saleValue[k];
  1888. // });
  1889. } else {
  1890. this.$message.warning("请填写完整信息");
  1891. }
  1892. });
  1893. },
  1894. // 单号生成
  1895. getOrderNo() {
  1896. let year = new Date().getFullYear();
  1897. let month = new Date().getMonth() + 1;
  1898. let day = new Date().getDate();
  1899. if (month < 10) {
  1900. month = "0" + month;
  1901. }
  1902. if (day < 10) {
  1903. day = "0" + day;
  1904. }
  1905. let hour = new Date().getHours();
  1906. let minute = new Date().getMinutes();
  1907. let second = new Date().getSeconds();
  1908. if (hour < 10) {
  1909. hour = "0" + hour;
  1910. }
  1911. if (minute < 10) {
  1912. minute = "0" + minute;
  1913. }
  1914. if (second < 10) {
  1915. second = "0" + second;
  1916. }
  1917. let orderNo = year + month + day + hour + minute + second;
  1918. return orderNo;
  1919. },
  1920. // 审计 编辑回调
  1921. async handleEdit(index, row) {
  1922. console.log(row);
  1923. let { saleOrderSaleNo } = row;
  1924. try {
  1925. let payLoad = [
  1926. {
  1927. basicMap: {
  1928. tableName: "sale_order",
  1929. },
  1930. conditionMap: {
  1931. sale_no: [saleOrderSaleNo],
  1932. },
  1933. },
  1934. {
  1935. basicMap: {
  1936. tableName: "sale_products",
  1937. },
  1938. conditionMap: {
  1939. sale_order_no: [saleOrderSaleNo],
  1940. },
  1941. },
  1942. {
  1943. basicMap: {
  1944. tableName: "sale_craft",
  1945. },
  1946. conditionMap: {
  1947. sale_order_no: [saleOrderSaleNo],
  1948. },
  1949. },
  1950. ];
  1951. let res = await queryDropDownBoxData(payLoad);
  1952. if (res.code == 200) {
  1953. this.isEdit = true;
  1954. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  1955. Object.assign(this.formData, {
  1956. ...sale_craft[0],
  1957. ...sale_order[0],
  1958. });
  1959. let { saleDate, saleOrderEstimatedTime, deliveryDate } =
  1960. sale_order[0];
  1961. saleDate && (this.formData.saleDate = new Date(saleDate));
  1962. saleOrderEstimatedTime &&
  1963. (this.formData.saleOrderEstimatedTime = saleOrderEstimatedTime);
  1964. deliveryDate && (this.formData.deliveryDate = new Date(deliveryDate));
  1965. this.productIds = sale_products.map((item) => item.saleProductNo);
  1966. await this.getDropDownData();
  1967. this.productionTableData = sale_products.map((item) => {
  1968. item.productType = this.allProductionOptions.find(
  1969. (i) => item.productNo == i.productNo
  1970. )?.productType;
  1971. return item;
  1972. });
  1973. if (this.formData.saleCustomNo) {
  1974. this.customChangeHandler(this.formData.saleCustomNo);
  1975. }
  1976. this.title = "编辑审计单";
  1977. this.open = true;
  1978. }
  1979. } catch (error) {
  1980. console.log(error);
  1981. }
  1982. },
  1983. // 审计 批量删除回调
  1984. async batchDelete() {
  1985. if (!this.ids.length) return;
  1986. try {
  1987. await this.$confirm("是否确认删除选中的数据?", "警告", {
  1988. confirmButtonText: "确定",
  1989. cancelButtonText: "取消",
  1990. type: "warning",
  1991. });
  1992. let orderPayload = {
  1993. basicMap: {
  1994. tableName: "sale_order",
  1995. },
  1996. conditionMap: {
  1997. saleNo: this.ids,
  1998. },
  1999. };
  2000. let productsPayload = {
  2001. basicMap: {
  2002. tableName: "sale_products",
  2003. },
  2004. conditionMap: {
  2005. saleOrderNo: this.ids,
  2006. },
  2007. };
  2008. let craftPayload = {
  2009. basicMap: {
  2010. tableName: "sale_craft",
  2011. },
  2012. conditionMap: {
  2013. saleOrderNo: this.ids,
  2014. },
  2015. };
  2016. let orderRes = await delTableData(orderPayload);
  2017. // let productRes = await delTableData(productsPayload);
  2018. // let craftRes = await delTableData(craftPayload);
  2019. if (orderRes.code == 200) {
  2020. this.$message.success("删除成功");
  2021. this.getList();
  2022. } else {
  2023. this.$message.error("删除失败");
  2024. throw Error("删除失败");
  2025. }
  2026. this.ids = [];
  2027. this.$refs.tableRef.clearSelection();
  2028. } catch (error) {
  2029. console.log(error);
  2030. }
  2031. },
  2032. // 计算金额
  2033. computedPrice(row) {
  2034. let { productNumber, productUnitPrice } = row;
  2035. console.log(
  2036. "productNumber, productUnitPrice",
  2037. productNumber,
  2038. productUnitPrice
  2039. );
  2040. row.productAmounts = (
  2041. Number(productNumber) * Number(productUnitPrice)
  2042. ).toFixed(2);
  2043. },
  2044. isUpperCase(char) {
  2045. return char === char.toUpperCase();
  2046. },
  2047. // 下划线命名转驼峰命名
  2048. toUnderScoreCase(str) {
  2049. if (str === null) {
  2050. return null;
  2051. }
  2052. let sb = "";
  2053. // 前置字符是否大写
  2054. let preCharIsUpperCase = true;
  2055. // 当前字符是否大写
  2056. let curreCharIsUpperCase = true;
  2057. // 下一字符是否大写
  2058. let nexteCharIsUpperCase = true;
  2059. for (let i = 0; i < str.length; i++) {
  2060. let c = str.charAt(i);
  2061. if (i > 0) {
  2062. preCharIsUpperCase = isUpperCase(str.charAt(i - 1));
  2063. } else {
  2064. preCharIsUpperCase = false;
  2065. }
  2066. curreCharIsUpperCase = isUpperCase(c);
  2067. if (i < str.length - 1) {
  2068. nexteCharIsUpperCase = isUpperCase(str.charAt(i + 1));
  2069. }
  2070. if (
  2071. preCharIsUpperCase &&
  2072. curreCharIsUpperCase &&
  2073. !nexteCharIsUpperCase
  2074. ) {
  2075. sb += SEPARATOR;
  2076. } else if (i !== 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
  2077. sb += SEPARATOR;
  2078. }
  2079. sb += c.toLowerCase();
  2080. }
  2081. return sb;
  2082. },
  2083. // 处理列表信息
  2084. columnsHandler(columns) {
  2085. let resArr = [];
  2086. console.log(columns, 111);
  2087. columns.forEach((item) => {
  2088. for (const key in item) {
  2089. let tempObj = {};
  2090. tempObj.key = camelCase(key);
  2091. tempObj.value = item[key];
  2092. resArr.push(tempObj);
  2093. }
  2094. });
  2095. console.log(resArr, 222);
  2096. return resArr;
  2097. },
  2098. // 取消按钮
  2099. cancel() {
  2100. this.open = false;
  2101. // this.reset();
  2102. },
  2103. // k-form-build 取消按钮
  2104. kCancel() {
  2105. this.kOpen = false;
  2106. // this.reset();
  2107. },
  2108. // 分页查询
  2109. pageList(row) {
  2110. // 调用子组件-》携带子组件参数请求后台
  2111. this.$refs.mychild.pageList(
  2112. row == undefined
  2113. ? {
  2114. limit: this.queryParams.pageSize,
  2115. page: this.queryParams.pageNum,
  2116. }
  2117. : row
  2118. );
  2119. },
  2120. // 多选框选中数据
  2121. handleSelectionChange(selection) {
  2122. // this.ids = selection.map(
  2123. // (item) =>
  2124. // item[
  2125. // camelCase(
  2126. // this.tableName + "_" + this.templateInfo.template?.primaryKey
  2127. // )
  2128. // ]
  2129. // );
  2130. this.selection = selection;
  2131. this.myDelIds = selection.map((item) => item.id);
  2132. console.log(this.myDelIds);
  2133. this.ids = selection.map((item) => item.saleOrderSaleNo);
  2134. this.single = selection.length != 1;
  2135. this.multiple = !selection.length;
  2136. },
  2137. // 更多操作触发
  2138. handleCommand(command, row) {
  2139. switch (command) {
  2140. case "handleResetPwd":
  2141. this.handleResetPwd(row);
  2142. break;
  2143. case "handleAuthRole":
  2144. this.handleAuthRole(row);
  2145. break;
  2146. default:
  2147. break;
  2148. }
  2149. },
  2150. /** 新增按钮操作 */
  2151. handleAdd(row) {
  2152. // this.reset();
  2153. this.defaultValue = {};
  2154. getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  2155. if (!data || !data.dfVueTemplate) {
  2156. this.jsonData = false;
  2157. this.$message.error("当前表格未绑定表单!");
  2158. return;
  2159. }
  2160. if (data.dfFormSql) {
  2161. let dynamicData = JSON.parse(data.dfFormSql);
  2162. Object.assign(this.dynamicData, dynamicData);
  2163. }
  2164. this.jsonData = JSON.parse(data.dfVueTemplate);
  2165. this.open = true;
  2166. this.title = "添加信息";
  2167. this.form.password = this.initPassword;
  2168. this.$nextTick(() => {
  2169. this.$refs.addFromRef.reset();
  2170. inputDisableComplete();
  2171. });
  2172. });
  2173. },
  2174. longestCommonSubstring(strs) {
  2175. if (!strs || strs.includes("")) return "";
  2176. let str1_Length = strs[0].length;
  2177. let str_Nums = strs.length;
  2178. let flag = 0;
  2179. for (let i = 0; i < str1_Length && flag == 0; i++) {
  2180. let char = strs[0][i];
  2181. for (var j = 1; j < str_Nums; j++) {
  2182. if (char !== strs[j][i] || i == strs[j].length) {
  2183. return strs[1].substring(0, i);
  2184. }
  2185. }
  2186. }
  2187. return strs[0];
  2188. },
  2189. // 绑定dialog对话框关闭
  2190. handleClose() {
  2191. this.btnDialogVisible = false;
  2192. },
  2193. getLastUppercaseWord(text) {
  2194. const pattern = /\b[A-Z][a-z]*\b/g;
  2195. const matches = [...text.matchAll(pattern)];
  2196. if (matches.length > 0) {
  2197. const lastMatch = matches[matches.length - 1][0];
  2198. return lastMatch;
  2199. } else {
  2200. return null;
  2201. }
  2202. },
  2203. // 初始化数据
  2204. async initData(data) {
  2205. let {
  2206. id,
  2207. //订单表数据
  2208. saleNo,
  2209. saleCustomNo,
  2210. saleDate,
  2211. saleOrderEstimatedTime,
  2212. saleLeadTime,
  2213. deliveryDate,
  2214. saleAmounts,
  2215. saleAmountInWords,
  2216. salePayType,
  2217. salesman,
  2218. customAddress,
  2219. customCountryType, //国家类型
  2220. contactPerson, //联系人
  2221. truckRegistration, //货车登记
  2222. // 工艺表数据
  2223. remark,
  2224. // 产品列表
  2225. saleProductsList,
  2226. } = data;
  2227. this.form.truckRegistration = truckRegistration;
  2228. Object.assign(this.formData, {
  2229. id,
  2230. //订单表数据
  2231. saleNo,
  2232. saleCustomNo,
  2233. saleDate,
  2234. saleOrderEstimatedTime,
  2235. saleLeadTime,
  2236. deliveryDate,
  2237. saleAmounts,
  2238. saleAmountInWords,
  2239. salePayType,
  2240. salesman,
  2241. customAddress,
  2242. customCountryType, //国家类型
  2243. contactPerson, //联系人
  2244. // 工艺表数据
  2245. orderRemark: remark,
  2246. });
  2247. this.customChangeHandler(saleCustomNo);
  2248. let promiseArr = [],
  2249. promiseArr2 = [];
  2250. this.productionTableData = saleProductsList.map((item, index) => {
  2251. let {
  2252. id,
  2253. saleProductNo,
  2254. productNo, //货品编号
  2255. productName, //货品名称
  2256. productNumber, //销售数量
  2257. productWeight, //销售重量kg
  2258. productUnitPrice, //单价
  2259. productAmounts, //金额
  2260. sliceType, //切片类型 初始为 切片
  2261. sliceTypeLabel,
  2262. colourNumberLabel,
  2263. colours, //色号
  2264. remark, //备注
  2265. lotNumber, //批号
  2266. } = item;
  2267. let targetItem = this.allProductionOptions.find(
  2268. (i) => item.productNo == i.productNo
  2269. );
  2270. // item.productType = targetItem?.productType;
  2271. let productType = targetItem?.productType;
  2272. let productSpecifications = targetItem?.productSpecifications;
  2273. promiseArr[index] = getProductSpecificationsByProductName({
  2274. productName: item.productName,
  2275. });
  2276. promiseArr2[index] = getProductInventory({
  2277. productNo,
  2278. productType,
  2279. lotNumber,
  2280. productName,
  2281. productSpecifications,
  2282. });
  2283. return {
  2284. id,
  2285. saleProductNo,
  2286. productSpecifications, //规格
  2287. productNo, //货品编号
  2288. productType, //类型
  2289. productName, //货品名称
  2290. productNumber, //销售数量
  2291. productWeight, //销售重量kg
  2292. productUnitPrice, //单价
  2293. productAmounts, //金额
  2294. sliceType, //切片类型 初始为 切片
  2295. sliceTypeLabel,
  2296. colourNumberLabel,
  2297. colours, //色号
  2298. remark,
  2299. lotNumber,
  2300. inventoryBoxNum: 0,
  2301. inventoryWeight: 0,
  2302. specificationsList: [],
  2303. };
  2304. });
  2305. let promiseRes = await Promise.all(promiseArr);
  2306. promiseRes.forEach((item, index) => {
  2307. this.productionTableData[index].specificationsList = item.data;
  2308. });
  2309. let promiseRes2 = await Promise.all(promiseArr2);
  2310. promiseRes2.forEach((item, index) => {
  2311. this.productionTableData[index].inventoryWeight =
  2312. item.data.inventoryWeight || 0;
  2313. this.productionTableData[index].inventoryBoxNum =
  2314. item.data.inventoryBoxNum || 0;
  2315. });
  2316. // this.productionTableData.forEach((item, index) => {
  2317. // item.inventoryWeight=promiseArr2[index].
  2318. // });
  2319. this.initTableValidate();
  2320. },
  2321. /** 修改按钮操作 */
  2322. async handleUpdate(row) {
  2323. console.log(row);
  2324. this.isEdit = true;
  2325. await this.getDropDownData();
  2326. this.isLeader = !this.userInfo.roles.includes("salesman");
  2327. if (!this.isLeader) {
  2328. this.createById = this.userInfo.userId;
  2329. }
  2330. await this.getRoleUser();
  2331. this.title = "修改零售单";
  2332. try {
  2333. let res = await getRetailOrderInfo(row.id);
  2334. console.log(res);
  2335. if (res.code == 200) {
  2336. this.initData(res.data);
  2337. this.open = true;
  2338. } else {
  2339. this.$message.error(res.msg);
  2340. }
  2341. } catch (error) {
  2342. console.log(error);
  2343. }
  2344. },
  2345. //详情 打印回调
  2346. async handlePrint(row) {
  2347. await this.getDropDownData();
  2348. this.isLeader = !this.userInfo.roles.includes("salesman");
  2349. if (!this.isLeader) {
  2350. this.createById = this.userInfo.userId;
  2351. }
  2352. await this.getRoleUser();
  2353. try {
  2354. let res = await getRetailOrderInfo(row.id);
  2355. console.log(res);
  2356. if (res.code == 200) {
  2357. await this.initData(res.data);
  2358. this.printDomData = this.getPrintDom(res.data);
  2359. this.detailShow = true;
  2360. this.$nextTick(() => {
  2361. this.$refs.detailTable.innerHTML = this.printDomData;
  2362. });
  2363. } else {
  2364. this.$message.error(res.msg);
  2365. }
  2366. } catch (error) {
  2367. console.log(error);
  2368. }
  2369. },
  2370. // 提交 回调
  2371. async handleSubmit(row) {
  2372. this.deliverShow = true;
  2373. this.$nextTick(() => {
  2374. this.$refs.deliverRef.productInvoiceInfo(row);
  2375. });
  2376. },
  2377. // 取消提交
  2378. async handleSubmitCancel(row) {
  2379. console.log(row);
  2380. this.$confirm("此操作将撤回该次提交, 是否继续?", "提示", {
  2381. confirmButtonText: "确定",
  2382. cancelButtonText: "取消",
  2383. type: "warning",
  2384. })
  2385. .then(async () => {
  2386. // this.$message({
  2387. // type: 'success',
  2388. // message: '删除成功!'
  2389. // });
  2390. try {
  2391. let { saleNo } = row;
  2392. let payLoad = {
  2393. saleOrderNo: saleNo,
  2394. status: 1,
  2395. };
  2396. let res = await cancelRetailOrder(payLoad);
  2397. if (res.code == 200) {
  2398. this.$message.success("取消成功");
  2399. this.getList();
  2400. } else {
  2401. this.$message.error("取消失败");
  2402. console.log(res);
  2403. }
  2404. } catch (error) {
  2405. console.log(error);
  2406. }
  2407. })
  2408. .catch(() => {
  2409. this.$message({
  2410. type: "info",
  2411. message: "已取消",
  2412. });
  2413. });
  2414. },
  2415. // 获取打印dom
  2416. getPrintDom(data) {
  2417. let {
  2418. id,
  2419. //订单表数据
  2420. saleNo,
  2421. saleCustomNo,
  2422. saleDate,
  2423. saleOrderEstimatedTime,
  2424. saleLeadTime,
  2425. deliveryDate,
  2426. saleAmounts,
  2427. saleAmountInWords,
  2428. salePayType,
  2429. salesman,
  2430. customAddress,
  2431. customCountryType, //国家类型
  2432. contactPerson, //联系人
  2433. // 工艺表数据
  2434. orderRemark,
  2435. } = this.formData;
  2436. console.log(this.form, this.productionTableData);
  2437. let { truckRegistration } = this.form;
  2438. let customData = this.customerOptions.find(
  2439. (item) => item.customNo == saleCustomNo
  2440. );
  2441. let customerName = customData ? customData.customName : "";
  2442. let printStr = `
  2443. <table style="width:1200px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  2444. <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
  2445. <div style="text-align:center;">销售合同审计单</div>
  2446. <tbody>
  2447. <tr>
  2448. <td width="600px" colspan="4">合同号:${saleNo}</td>
  2449. <td width="600px" colspan="5">日期:${saleDate.replace(
  2450. "T",
  2451. " "
  2452. )}</td>
  2453. </tr>
  2454. <tr align="center">
  2455. <td width="300px" colspan="2">客户名称:</td>
  2456. <td width="300px" colspan="3">${customerName}</td>
  2457. <td colspan="2">业务员:</td>
  2458. <td colspan="2">${salesman}</td>
  2459. </tr>
  2460. <tr align="center">
  2461. <td width="300px" colspan="2">客户地址:</td>
  2462. <td width="300px" colspan="3">${customAddress}</td>
  2463. <td width="300px" colspan="2">客户国别:</td>
  2464. <td width="300px" colspan="2">${customCountryType}</td>
  2465. </tr>
  2466. <tr align="center">
  2467. <td width="300px" colspan="2">联系人:</td>
  2468. <td width="150px" colspan="2">${contactPerson}</td>
  2469. <td colspan="2">合计金额(大写):</td>
  2470. <td colspan="3">${saleAmountInWords}</td>
  2471. </tr>
  2472. <tr align="center">
  2473. <td colspan="9">货品明细</td>
  2474. </tr>
  2475. <tr align="center">
  2476. <td width="150px">品名</td>
  2477. <td width="100px">规格</td>
  2478. <td width="100px">色号</td>
  2479. <td width="100px">类型</td>
  2480. <td width="100px">批号</td>
  2481. <td width="100px">箱数</td>
  2482. <td width="100px">单价</td>
  2483. <td width="100px">金额</td>
  2484. <td width="100px">备注</td>
  2485. </tr>`;
  2486. let amountTotal = 0,
  2487. singlTotal = 0,
  2488. moneyTotal = 0;
  2489. for (let i = 0; i < this.productionTableData.length; i++) {
  2490. let item = this.productionTableData[i];
  2491. amountTotal += Number(item.productNumber);
  2492. singlTotal += Number(item.productUnitPrice);
  2493. moneyTotal += Number(item.productAmounts);
  2494. let productData = this.allProductionOptions.find(
  2495. (pro) => pro.productNo == item.productNo
  2496. );
  2497. item.sliceTypeLabel =
  2498. this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
  2499. ?.materielName || "";
  2500. // item.colourNumberLabel = this.colourNumberOptions.find(
  2501. // (k) => k.colour == item.colours
  2502. // )?.colour;
  2503. item.colourNumberLabel = item.colours;
  2504. let productName = productData ? productData.productName : "";
  2505. let productType = productData ? productData.productType : "";
  2506. printStr += `<tr align="center">
  2507. <td>${item.productName}</td>
  2508. <td>${item.productSpecifications}</td>
  2509. <td>${item.colourNumberLabel}</td>
  2510. <td>${item.productType}</td>
  2511. <td>${item.lotNumber}</td>
  2512. <td>${item.productNumber}</td>
  2513. <td>${item.productUnitPrice}</td>
  2514. <td>${item.productAmounts}</td>
  2515. <td>${item.remark}</td>
  2516. </tr>`;
  2517. }
  2518. // 计算小计
  2519. amountTotal = amountTotal;
  2520. singlTotal = singlTotal.toFixed(2);
  2521. moneyTotal = moneyTotal.toFixed(2);
  2522. printStr += `
  2523. <tr align="center">
  2524. <td>小计:</td>
  2525. <td></td>
  2526. <td></td>
  2527. <td></td>
  2528. <td></td>
  2529. <td>${amountTotal}</td>
  2530. <td>${singlTotal}</td>
  2531. <td>${moneyTotal}</td>
  2532. <td></td>
  2533. </tr>`;
  2534. printStr += `<tr align="left">
  2535. <td colspan="9">订单备注:${orderRemark}</td>
  2536. </tr>
  2537. </tbody>
  2538. </table>`;
  2539. return printStr;
  2540. },
  2541. // 添加真正的字段名
  2542. addRealFieldName(row) {
  2543. let fieldList = Object.keys(row);
  2544. // let tableName = this.longestCommonSubstring(fieldList);
  2545. let tableName = camelCase(this.tableName);
  2546. fieldList.forEach((field) => {
  2547. let realField = field.replace(tableName, "");
  2548. realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  2549. row[realField] = row[field];
  2550. });
  2551. },
  2552. /** 提交按钮 */
  2553. submitForm: function () {
  2554. this.$refs["form"].validate((valid) => {
  2555. if (valid) {
  2556. if (this.form.userId != undefined) {
  2557. updateUser(this.form).then((response) => {
  2558. this.$modal.msgSuccess("修改成功");
  2559. this.open = false;
  2560. this.getList();
  2561. });
  2562. } else {
  2563. addUser(this.form).then((response) => {
  2564. this.$modal.msgSuccess("新增成功");
  2565. this.open = false;
  2566. this.getList();
  2567. });
  2568. }
  2569. }
  2570. });
  2571. },
  2572. /** 删除按钮操作
  2573. *
  2574. * 删除提示信息语句(标识)
  2575. * */
  2576. handleDelete(row, btnData) {
  2577. let delIds = this.ids;
  2578. let primary = camelCase(this.templateInfo.template?.primaryKey);
  2579. // let realyKey=
  2580. this.addRealFieldName(row);
  2581. if (row[primary] != undefined && row[primary] != null) {
  2582. delIds = [];
  2583. delIds.push(row[primary]);
  2584. }
  2585. let data = {
  2586. basicMap: {
  2587. btnType: btnData.btnType,
  2588. btnKey: btnData.btnKey,
  2589. tableName: this.tableName,
  2590. },
  2591. conditionMap: {
  2592. // id: delIds,
  2593. },
  2594. btnParametersMap: {},
  2595. };
  2596. if (this.currentBtnData.btnParams) {
  2597. let btnParams =
  2598. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2599. let conditionData =
  2600. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2601. conditionData.forEach((item) => {
  2602. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2603. ? item.fieldValue
  2604. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2605. });
  2606. btnParams.forEach((item) => {
  2607. data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
  2608. ? item.fieldValue
  2609. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2610. });
  2611. }
  2612. // data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  2613. this.$modal
  2614. .confirm('是否确认删除"' + delIds + '"的数据项?')
  2615. .then(function () {
  2616. // return delTableData(data);
  2617. return btnCommonApi(data);
  2618. })
  2619. .then(() => {
  2620. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2621. this.$refs.mychild.pageList();
  2622. this.$modal.msgSuccess("删除成功");
  2623. })
  2624. .catch(() => {});
  2625. },
  2626. // 批量删除接口
  2627. handleBatchDelete() {
  2628. let delIds = this.ids;
  2629. let primary = camelCase(this.templateInfo.template?.primaryKey);
  2630. // if (row && row[primary] != undefined && row[primary] != null) {
  2631. // delIds = [];
  2632. // delIds.push(row[primary]);
  2633. // }
  2634. let data = {
  2635. basicMap: {
  2636. tableName: this.tableName,
  2637. },
  2638. conditionMap: {
  2639. // id: delIds,
  2640. },
  2641. };
  2642. // if (this.currentBtnData.btnParams) {
  2643. // let btnParams = JSON.parse(this.currentBtnData.btnParams);
  2644. // btnParams.forEach((item) => {
  2645. // data.btnParametersMap[
  2646. // this.formatField(item.fieldName, camelCase(this.tableName))
  2647. // ] = item.fieldValue
  2648. // ? item.fieldValue
  2649. // : this.currentRow[item.fieldName];
  2650. // });
  2651. // }
  2652. data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  2653. this.$modal
  2654. .confirm('是否确认删除"' + delIds + '"的数据项?')
  2655. .then(function () {
  2656. return delTableData(data);
  2657. // return btnCommonApi(data);
  2658. })
  2659. .then(() => {
  2660. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2661. this.$refs.mychild.pageList();
  2662. this.$modal.msgSuccess("删除成功");
  2663. })
  2664. .catch(() => {});
  2665. },
  2666. /** 导出按钮操作 */
  2667. handleExport() {
  2668. let primary = "saleOrderId";
  2669. let realyKey = "saleOrderId";
  2670. if (this.myDelIds.length > 0) {
  2671. this.queryParams["execlMap"] = [];
  2672. this.myDelIds.forEach((item) => {
  2673. this.queryParams.execlMap.push(
  2674. this.tableList.find((ttem) => {
  2675. return ttem[realyKey] === item;
  2676. })
  2677. );
  2678. });
  2679. } else {
  2680. this.$message.warning("请至少勾选一条导出数据");
  2681. return;
  2682. }
  2683. this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
  2684. this.download(
  2685. process.env.VUE_APP_BASE_API1 + "common/export",
  2686. {
  2687. ...this.queryParams,
  2688. },
  2689. `文件名称_${new Date().getTime()}.xlsx`
  2690. );
  2691. },
  2692. /** 导入按钮操作 */
  2693. handleImport() {
  2694. this.upload.title = "当前导入";
  2695. this.upload.open = true;
  2696. },
  2697. /** 下载模板操作 */
  2698. importTemplate() {
  2699. this.download(
  2700. process.env.VUE_APP_BASE_API1 +
  2701. `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
  2702. {},
  2703. `下载模版名称${new Date().getTime()}.xlsx`
  2704. );
  2705. },
  2706. // 文件上传中处理
  2707. handleFileUploadProgress(event, file, fileList) {
  2708. this.upload.isUploading = true;
  2709. },
  2710. // 文件上传成功处理
  2711. handleFileSuccess(response, file, fileList) {
  2712. this.upload.open = false;
  2713. this.upload.isUploading = false;
  2714. this.$refs.upload.clearFiles();
  2715. this.$alert(
  2716. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  2717. response.msg +
  2718. "</div>",
  2719. "导入结果",
  2720. { dangerouslyUseHTMLString: true }
  2721. );
  2722. this.$refs.mychild.pageList({
  2723. limit: this.queryParams.pageSize,
  2724. page: this.queryParams.pageNum,
  2725. });
  2726. },
  2727. //重点在这里
  2728. handleChange(file, fileList) {
  2729. file.name = this.tableName + "." + file.name.split(".")[1];
  2730. fileList.forEach((item) => {
  2731. item.name = this.tableName + "." + file.name.split(".")[1];
  2732. });
  2733. let newFile = new File(
  2734. [file],
  2735. this.tableName + "." + file.name.split(".")[1]
  2736. ); //创建出来也是不可编辑的file对象
  2737. },
  2738. // 提交上传文件
  2739. submitFileForm() {
  2740. this.$refs.upload.submit();
  2741. },
  2742. // 弹窗新增的数
  2743. addListHandler(val) {
  2744. this.addLists.push(...val);
  2745. },
  2746. // 绑定弹窗Dialog确定按钮
  2747. async btnComfirm() {
  2748. let res = await this.$refs.deliverRef.getAllData();
  2749. let { flag, isEdit, data } = res;
  2750. if (flag) {
  2751. // if (isEdit) {
  2752. // //编辑
  2753. // let payLoad = {
  2754. // ...data.formData,
  2755. // saleProductInfoList: data.tableData,
  2756. // };
  2757. // let res = await updateProductInvoice(payLoad);
  2758. // if (res.code == 200) {
  2759. // this.$message.success("修改成功");
  2760. // this.deliverShow = false;
  2761. // this.getList();
  2762. // } else {
  2763. // this.$message.error("网络异常");
  2764. // }
  2765. // } else {
  2766. //新增
  2767. let payLoad = {
  2768. ...data.formData,
  2769. saleProductInfoList: data.tableData,
  2770. };
  2771. // let res = await addProductInvoice(payLoad);
  2772. let reqAPI = isEdit ? submitProductInvoice : submitRetailOrder;
  2773. if (!isEdit) {
  2774. payLoad.status = 5;
  2775. }
  2776. let res = await reqAPI(payLoad);
  2777. if (res.code == 200) {
  2778. this.$message.success("提交成功");
  2779. this.deliverShow = false;
  2780. this.getList();
  2781. } else {
  2782. this.$message.error("网络异常");
  2783. }
  2784. // }
  2785. }
  2786. },
  2787. // 保存提交数据
  2788. async btnSave() {
  2789. let res = await this.$refs.deliverRef.getAllData();
  2790. let { flag, isEdit, data } = res;
  2791. if (flag) {
  2792. let payLoad = {
  2793. ...data.formData,
  2794. saleProductInfoList: data.tableData,
  2795. };
  2796. payLoad.status = 1;
  2797. let res = await updateProductInvoice(payLoad);
  2798. if (res.code == 200) {
  2799. this.$message.success("保存成功");
  2800. this.deliverShow = false;
  2801. this.getList();
  2802. } else {
  2803. this.$message.error("网络异常");
  2804. }
  2805. // }
  2806. }
  2807. },
  2808. // 去掉表名 开头字母小写
  2809. formatField(field = "", tableName) {
  2810. let temp = field.replace(tableName, "");
  2811. return toUnderline(temp[0].toLowerCase() + temp.slice(1));
  2812. },
  2813. //提交编辑结果按钮回调
  2814. async editConfirmHandler() {
  2815. if (this.$refs.addFromRef) {
  2816. this.$refs.addFromRef
  2817. .getData()
  2818. .then(async (values) => {
  2819. let data = {
  2820. basicMap: {
  2821. tableName: this.tableName,
  2822. // btnKey: btnData.btnKey,
  2823. btnKey: this.currentBtnData.btnKey,
  2824. },
  2825. addListMap: [values],
  2826. conditionMap: {},
  2827. commMap: {},
  2828. btnParametersMap: {},
  2829. };
  2830. if (this.currentBtnData.btnParams) {
  2831. let btnParams =
  2832. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
  2833. [];
  2834. let conditionData =
  2835. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2836. // let
  2837. btnParams.forEach((item) => {
  2838. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2839. item.fieldValue
  2840. ? item.fieldValue
  2841. : this.currentRow[
  2842. camelCase(item.fieldName.replace(".", "_"))
  2843. ];
  2844. });
  2845. conditionData.forEach((item) => {
  2846. data.conditionMap[item.fieldName.split(".")[1]] =
  2847. item.fieldValue
  2848. ? item.fieldValue
  2849. : this.currentRow[
  2850. camelCase(item.fieldName.replace(".", "_"))
  2851. ];
  2852. });
  2853. }
  2854. if (Object.keys(this.defaultValue).length) {
  2855. // data.conditionMap[this.templateInfo.template?.primaryKey] =
  2856. // this.defaultValue[this.templateInfo.template?.primaryKey];
  2857. Object.keys(values).map((k) => {
  2858. data.commMap[k] = values[k];
  2859. });
  2860. data.basicMap.btnType = this.currentBtnData.btnType;
  2861. data.basicMap.visible = true;
  2862. } else {
  2863. data.basicMap.btnType = "INSERT";
  2864. data.basicMap.visible = true;
  2865. }
  2866. try {
  2867. let res = await btnCommonApi(data);
  2868. if (res.code == 200) {
  2869. this.$message.success("操作成功");
  2870. } else {
  2871. this.$message.error("网络异常,请稍后再试");
  2872. }
  2873. } catch (error) {
  2874. console.log(error);
  2875. this.$message.error("网络异常,请稍后再试");
  2876. }
  2877. this.getList();
  2878. this.defaultValue = {};
  2879. this.kOpen = false;
  2880. })
  2881. .catch((res) => {
  2882. console.log(res);
  2883. this.$modal.msgError("表单校验失败,请规范填写数据");
  2884. });
  2885. } else {
  2886. // 没有绑定表单
  2887. let data = {
  2888. basicMap: {
  2889. tableName: this.tableName,
  2890. // btnKey: btnData.btnKey,
  2891. btnKey: this.currentBtnData.btnKey,
  2892. btnType: this.currentBtnData.btnType,
  2893. visible: true,
  2894. },
  2895. addListMap: [],
  2896. conditionMap: {},
  2897. commMap: {},
  2898. btnParametersMap: {},
  2899. };
  2900. if (this.currentBtnData.btnParams) {
  2901. let btnParams =
  2902. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2903. let conditionData =
  2904. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2905. conditionData.forEach((item) => {
  2906. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2907. ? item.fieldValue
  2908. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2909. });
  2910. btnParams.forEach((item) => {
  2911. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2912. item.fieldValue
  2913. ? item.fieldValue
  2914. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2915. });
  2916. }
  2917. // data.basicMap.btnType = this.currentBtnData.btnType;
  2918. // data.basicMap.visible = true;
  2919. try {
  2920. let res = await btnCommonApi(data);
  2921. if (res.code == 200) {
  2922. this.$message.success("操作成功");
  2923. } else {
  2924. this.$message.error("网络异常,请稍后再试");
  2925. }
  2926. } catch (error) {
  2927. console.log(error);
  2928. this.$message.error("网络异常,请稍后再试");
  2929. }
  2930. this.getList();
  2931. this.defaultValue = {};
  2932. this.kOpen = false;
  2933. }
  2934. },
  2935. // 使用提交数据类型的按钮获取数据
  2936. tempSubBtn(getData) {
  2937. getData()
  2938. .then((values) => {
  2939. console.log("验证通过", values);
  2940. })
  2941. .catch(() => {
  2942. console.log("验证未通过,获取失败");
  2943. });
  2944. },
  2945. // 判断是否生效行样式
  2946. cellStyle({ row, column, rowIndex, columnIndex }) {
  2947. let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
  2948. if (!rowStyleList.length) return "";
  2949. let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
  2950. for (let i = 0; i < rowStyleList.length; i++) {
  2951. let item = rowStyleList[i];
  2952. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2953. if (judgeRes) {
  2954. let styleCode = JSON.parse(item.styleCode);
  2955. return `background-color:${styleCode.rowBgColor};`;
  2956. }
  2957. }
  2958. },
  2959. // 获取生效条件组结果
  2960. determineCondition(conditionStr, row) {
  2961. let conditionList = JSON.parse(conditionStr);
  2962. if (!conditionList.length) return false;
  2963. return conditionList.every((item) => this.judgeOneCondition(item, row));
  2964. },
  2965. // 获取单个判断条件结果
  2966. judgeOneCondition(item, row) {
  2967. let fullField = camelCase(item.tableName + "_" + item.fieldName);
  2968. switch (item.condition) {
  2969. case 1:
  2970. return row[fullField] > item.flagValue;
  2971. case 2:
  2972. return row[fullField] < item.flagValue;
  2973. case 3:
  2974. return row[fullField] == item.flagValue;
  2975. case 4:
  2976. return row[fullField] >= item.flagValue;
  2977. case 5:
  2978. return row[fullField] <= item.flagValue;
  2979. default:
  2980. return true; //默认为true
  2981. }
  2982. },
  2983. // 设置表格字段样式
  2984. async setFieldStyleData(tableList) {
  2985. console.log(JSON.parse(JSON.stringify(tableList)));
  2986. let fieldConditionList = this.styleList.filter(
  2987. (item) => item.styleType == 1 || item.styleType == 2
  2988. );
  2989. if (!fieldConditionList.length) return tableList;
  2990. let res = await this.setDictStyleData();
  2991. this.dictStyleObj = res.reduce((pre, item) => {
  2992. return {
  2993. ...pre,
  2994. ...item,
  2995. };
  2996. }, {});
  2997. // console.log("this.dictStyleObj", this.dictStyleObj);
  2998. tableList.forEach((row) => {
  2999. // if (!row.styleFieldObj) row.styleFieldObj = {};
  3000. for (let i = 0; i < fieldConditionList.length; i++) {
  3001. let item = fieldConditionList[i];
  3002. if (item.styleType == 1) {
  3003. //字段样式
  3004. let judgeRes = this.determineCondition(item.styleCondtion, row);
  3005. if (judgeRes) {
  3006. let styleCode = JSON.parse(item.styleCode);
  3007. if (!row.styleFieldObj) row.styleFieldObj = {};
  3008. row.styleFieldObj[item.styleField] = {
  3009. styleType: item.styleType,
  3010. fieldStyleType: styleCode.fieldStyleType,
  3011. fontColor: styleCode.fontColor,
  3012. isTagFullBg: styleCode.isTagFullBg,
  3013. tagType: styleCode.tagType,
  3014. };
  3015. // row.styleField = item.styleField; //样式生效字段
  3016. // row.styleType = item.styleType; //0:行样式 1:字段样式 2:字典样式
  3017. // row.fieldStyleType = styleCode.fieldStyleType; //0:文本 1:标签
  3018. // row.fontColor = styleCode.fontColor;
  3019. // row.isTagFullBg = styleCode.isTagFullBg; //true/false
  3020. // row.tagType = styleCode.tagType; //string
  3021. }
  3022. } else {
  3023. //字典样式
  3024. let dicStyle = this.dictStyleObj[item.styleField]?.find((dict) => {
  3025. return dict.dictValue == row[item.styleField];
  3026. });
  3027. if (dicStyle) {
  3028. if (!row.styleFieldObj) row.styleFieldObj = {};
  3029. row.styleFieldObj[item.styleField] = dicStyle; //设置该字段应该显示的字典样式
  3030. row.styleFieldObj[item.styleField].styleType = 2;
  3031. }
  3032. }
  3033. }
  3034. });
  3035. return tableList;
  3036. },
  3037. //设置表格字典相关数据
  3038. setDictStyleData() {
  3039. let fieldConditionList = this.styleList.filter(
  3040. (item) => item.styleType == 2
  3041. );
  3042. if (!fieldConditionList.length) return;
  3043. let PromiseList = fieldConditionList.map((item) => {
  3044. return new Promise((resolve, reject) => {
  3045. let temp = {};
  3046. try {
  3047. listData({
  3048. isEnablePaging: false,
  3049. dictType: item.styleCondtion,
  3050. }).then((res) => {
  3051. temp[item.styleField] = res.rows;
  3052. resolve(temp);
  3053. });
  3054. } catch (error) {
  3055. reject(error);
  3056. }
  3057. });
  3058. });
  3059. return Promise.all(PromiseList);
  3060. },
  3061. // 内链页面跳转
  3062. routerHandler(btnData, type) {
  3063. let { url, commonFieldData } = JSON.parse(btnData.btnParams);
  3064. let tempArr = [];
  3065. if (commonFieldData) {
  3066. let queryArr = JSON.parse(commonFieldData);
  3067. tempArr = queryArr.map((item) => {
  3068. let key = this.formatField(item.fieldName, camelCase(this.tableName));
  3069. let value = item.fieldValue
  3070. ? item.fieldValue
  3071. : this.currentRow[item.fieldName];
  3072. return key + "=" + value;
  3073. });
  3074. }
  3075. if (tempArr.length) {
  3076. url += "?" + tempArr.join("&");
  3077. }
  3078. // let link = btnData.btnParams;
  3079. if (type == "INNERLINK") {
  3080. this.$router.push(url);
  3081. } else {
  3082. window.open("http://" + url, "_blank");
  3083. }
  3084. },
  3085. async handleDetail(row) {
  3086. this.printDomData = await this.getDetailTableString(row);
  3087. this.detailShow = true;
  3088. this.$nextTick(() => {
  3089. this.$refs.detailTable.innerHTML = this.printDomData;
  3090. });
  3091. },
  3092. // 切片类型改变回调
  3093. sliceTypeChangeHandler(row) {
  3094. let { sliceType } = row;
  3095. if (sliceType) {
  3096. row.sliceTypeLabel = this.sliceTypeOptions.find(
  3097. (item) => item.materielCode == sliceType
  3098. )?.materielName;
  3099. }
  3100. },
  3101. // 色号改变回调
  3102. colourNumberChangeHandler(row) {
  3103. let { colours } = row;
  3104. if (colours) {
  3105. let target = this.colourNumberOptions.find(
  3106. (item) => item.colour == colours
  3107. );
  3108. if (target) {
  3109. row.colourNumberLabel =
  3110. target.materieEncoding + target.materieColorNumber;
  3111. }
  3112. // row.colourNumberLabel = this.colourNumberOptions.find(
  3113. // (item) => item.materielCode == colours
  3114. // )?.materieColorNumber;
  3115. this.updateStorage(row);
  3116. }
  3117. },
  3118. // 打印回调
  3119. detailPrintHandler() {
  3120. document.body.innerHTML = document.getElementById("printDom").innerHTML =
  3121. this.printDomData;
  3122. window.print(); //打印
  3123. window.location.reload();
  3124. return false;
  3125. },
  3126. // 根据字典value获取字典label
  3127. getDictLabel(value, dict) {
  3128. return (
  3129. this.dict.type[dict].find((item) => {
  3130. return item.value === value;
  3131. })?.label || ""
  3132. );
  3133. },
  3134. // 获取详情html字符串
  3135. async getDetailTableString(row) {
  3136. let { saleOrderSaleNo } = row;
  3137. let payLoad = [
  3138. {
  3139. basicMap: {
  3140. tableName: "sale_order",
  3141. },
  3142. conditionMap: {
  3143. sale_no: [saleOrderSaleNo],
  3144. },
  3145. },
  3146. {
  3147. basicMap: {
  3148. tableName: "sale_products",
  3149. },
  3150. conditionMap: {
  3151. sale_order_no: [saleOrderSaleNo],
  3152. },
  3153. },
  3154. {
  3155. basicMap: {
  3156. tableName: "sale_craft",
  3157. },
  3158. conditionMap: {
  3159. sale_order_no: [saleOrderSaleNo],
  3160. },
  3161. },
  3162. ];
  3163. let res = await queryDropDownBoxData(payLoad);
  3164. if (res.code == 200) {
  3165. console.log(res);
  3166. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  3167. let {
  3168. //订单表数据
  3169. saleNo, //合同号
  3170. lotNumber, //批号
  3171. saleCustomNo, //客户编号
  3172. saleDate, //销售单日期
  3173. saleOrderEstimatedTime, //预计下单时间
  3174. saleLeadTime, //交货周期
  3175. deliveryDate,
  3176. saleAmounts, //合计金额 小写
  3177. saleAmountInWords, //合计金额 大写
  3178. salePayType, //支付方式
  3179. earnestMoney,
  3180. salesman, //业务员
  3181. saleLeader, //业务主管
  3182. finance, //财务部
  3183. production, //生产部
  3184. saleApprover, //批准人
  3185. // customAddress, //客户地址
  3186. // customCountryType, //国家类型
  3187. // contactPerson, //联系人
  3188. // 货品明细表数据
  3189. // productNo, //货品号
  3190. // productName, //货品名称
  3191. // productNumber: "", //销售数量
  3192. // productWeight: "", //销售重量kg
  3193. // productUnitPrice: "", //单价
  3194. // productAmounts: "", //金额
  3195. // remark: "", //备注
  3196. // 工艺表
  3197. craftGrid, //网络
  3198. craftOil, //油剂
  3199. craftPackage, //卷装
  3200. craftColorFastness, //色牢度
  3201. directionOfTwist,
  3202. craftOther, //其它工艺要求
  3203. craftMark, //包装/贴唛
  3204. shippingMethod, //运输方式
  3205. } = { ...sale_craft[0], ...sale_order[0] };
  3206. let customData = this.customerOptions.find(
  3207. (item) => item.customNo == saleCustomNo
  3208. );
  3209. let payType = this.getDictLabel(salePayType, "payment_method"); //付款方式
  3210. let customerName = customData ? customData.customName : "";
  3211. let customAddress = customData?.customAddress || "无";
  3212. let customCountryType = customData?.customCountryType || "";
  3213. let contactPerson = customData?.contactPerson || "无";
  3214. let directionOfTwistDescription = directionOfTwist
  3215. ? this.getDictLabel(directionOfTwist, "direction_of_twist")
  3216. : "";
  3217. let printStr = `
  3218. <table style="width:1200px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  3219. <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
  3220. <div style="text-align:center;">销售合同审计单</div>
  3221. <tbody>
  3222. <tr>
  3223. <td width="600px" colspan="4">合同号:${saleNo}</td>
  3224. <td width="600px" colspan="4">日期:${saleDate.replace(
  3225. "T",
  3226. " "
  3227. )}</td>
  3228. </tr>
  3229. <tr align="center">
  3230. <td width="300px" colspan="2">客户名称:</td>
  3231. <td width="300px" colspan="2">${customerName}</td>
  3232. <td width="300px" colspan="2">联系人:</td>
  3233. <td width="150px" colspan="1">${contactPerson}</td>
  3234. </tr>
  3235. <tr align="center">
  3236. <td width="300px" colspan="2">客户地址:</td>
  3237. <td width="300px" colspan="2">${customAddress}</td>
  3238. <td width="300px" colspan="2">客户国别:</td>
  3239. <td width="300px" colspan="2">${customCountryType}</td>
  3240. </tr>
  3241. <tr align="center">
  3242. <td width="300px" colspan="2">预计下单时间:</td>
  3243. <td colspan="1">${saleOrderEstimatedTime.replace(
  3244. "T",
  3245. " "
  3246. )}</td>
  3247. <td colspan="1">交货周期:</td>
  3248. <td >${saleLeadTime}</td>
  3249. <td colspan="2">交货日期:</td>
  3250. <td >${deliveryDate.replace("T", " ")}</td>
  3251. </tr>
  3252. <tr align="center">
  3253. <td colspan="8">货品明细</td>
  3254. </tr>
  3255. <tr align="center">
  3256. <td width="150px">品名</td>
  3257. <td width="150px">类型</td>
  3258. <td width="150px">箱数</td>
  3259. <td width="150px">单价</td>
  3260. <td width="150px">金额</td>
  3261. <td width="150px">切片型号</td>
  3262. <td width="150px">色号</td>
  3263. <td width="150px">备注</td>
  3264. </tr>`;
  3265. let amountTotal = 0,
  3266. singlTotal = 0,
  3267. moneyTotal = 0;
  3268. for (let i = 0; i < sale_products.length; i++) {
  3269. let item = sale_products[i];
  3270. amountTotal += Number(item.productNumber);
  3271. singlTotal += Number(item.productUnitPrice);
  3272. moneyTotal += Number(item.productAmounts);
  3273. let productData = this.productionOptions.find(
  3274. (pro) => pro.productNo == item.productNo
  3275. );
  3276. console.log("item", item);
  3277. item.sliceTypeLabel =
  3278. this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
  3279. ?.materielName || "";
  3280. item.colourNumberLabel = this.colourNumberOptions.find(
  3281. (k) => k.colour == item.colours
  3282. )?.colour;
  3283. let productName = productData ? productData.productName : "";
  3284. let productType = productData ? productData.productType : "";
  3285. printStr += `<tr align="center">
  3286. <td>${productName}</td>
  3287. <td>${productType}</td>
  3288. <td>${item.productNumber}</td>
  3289. <td>${item.productUnitPrice}</td>
  3290. <td>${item.productAmounts}</td>
  3291. <td>${item.sliceTypeLabel}</td>
  3292. <td>${item.colourNumberLabel}</td>
  3293. <td>${item.remark}</td>
  3294. </tr>`;
  3295. }
  3296. // 计算小计
  3297. printStr += `
  3298. <tr align="center">
  3299. <td>小计:</td>
  3300. <td></td>
  3301. <td>${amountTotal}</td>
  3302. <td>${singlTotal}</td>
  3303. <td>${moneyTotal}</td>
  3304. <td></td>
  3305. <td></td>
  3306. <td></td>
  3307. </tr>
  3308. <tr>
  3309. <td colspan="8">合计金额(大写):${saleAmountInWords}</td>
  3310. </tr>
  3311. `;
  3312. if (salePayType == "1") {
  3313. //定金
  3314. printStr += `
  3315. <tr>
  3316. <td colspan="4">付款方式:${payType}</td>
  3317. <td colspan="4">定金:${earnestMoney}</td>
  3318. </tr>`;
  3319. } else {
  3320. printStr += `
  3321. <tr>
  3322. <td colspan="8">付款方式:${payType}</td>
  3323. </tr>`;
  3324. }
  3325. printStr += `<tr align="center">
  3326. <td colspan="8">工艺要求</td>
  3327. </tr>
  3328. <tr align="center">
  3329. <td width="150px">网络</td>
  3330. <td width="150px">油剂</td>
  3331. <td width="150px">卷装</td>
  3332. <td width="150px">色牢度</td>
  3333. <td width="150px">捻向</td>
  3334. <td width="150px">其他</td>
  3335. <td width="150px"></td>
  3336. <td width="150px"></td>
  3337. </tr>
  3338. <tr align="center">
  3339. <td >${craftGrid}</td>
  3340. <td>${craftOil}</td>
  3341. <td>${craftPackage}</td>
  3342. <td>${craftColorFastness}</td>
  3343. <td>${directionOfTwistDescription}</td>
  3344. <td>${craftOther}</td>
  3345. <td width="150px"></td>
  3346. <td width="150px"></td>
  3347. </tr>
  3348. <tr>
  3349. <td colspan="8">包装/贴唛:${craftMark}</td>
  3350. </tr>
  3351. <tr>
  3352. <td colspan="8">装运方式:${shippingMethod}</td>
  3353. </tr>
  3354. <tr align="center">
  3355. <td colspan="2">业务员:</td>
  3356. <td colspan="2">${salesman}</td>
  3357. <td colspan="2">财务部:</td>
  3358. <td colspan="2">${finance}</td>
  3359. </tr>
  3360. <tr align="center">
  3361. <td colspan="2">业务主管:</td>
  3362. <td colspan="2">${saleApprover}</td>
  3363. <td></td>
  3364. <td></td>
  3365. <td></td>
  3366. <td></td>
  3367. </tr>
  3368. </tbody>
  3369. </table>
  3370. `;
  3371. return printStr;
  3372. // <td colspan="2">业务主管:</td>
  3373. // <td colspan="2">${saleLeader}</td>
  3374. // <tr align="center">
  3375. // // <td colspan="2">生产部:</td>
  3376. // // <td colspan="2">${production}</td>
  3377. // </tr>
  3378. // <tr align="center">
  3379. // <td colspan="2"> 2</td>
  3380. // <td> </td>
  3381. // <td> </td>
  3382. // <td> </td>
  3383. // <td> </td>
  3384. // </tr>
  3385. // <tr>
  3386. // <td colspan="2">小计:</td>
  3387. // <td></td>
  3388. // <td></td>
  3389. // <td></td>
  3390. // <td></td>
  3391. // </tr>
  3392. }
  3393. },
  3394. // 自定义删除按钮
  3395. async myDeleteHandler(row) {
  3396. console.log(row);
  3397. let stateArr = ["6"];
  3398. let isDeleteValidate = this.selection.some((item) => {
  3399. return stateArr.includes(item.status);
  3400. });
  3401. console.log(this.selection);
  3402. console.log(isDeleteValidate);
  3403. if (isDeleteValidate) {
  3404. this.$message.error("'已完成'状态订单不可删除!");
  3405. return;
  3406. }
  3407. await this.$confirm("是否确认删除选中的数据?", "警告", {
  3408. confirmButtonText: "确定",
  3409. cancelButtonText: "取消",
  3410. type: "warning",
  3411. });
  3412. let payLoad = row.id ? [row.id] : this.myDelIds;
  3413. payLoad = payLoad.join(",");
  3414. console.log(payLoad);
  3415. try {
  3416. let res = await deleRetailOrder(payLoad);
  3417. if (res.code === 200) {
  3418. this.$message.success("删除成功");
  3419. this.getList();
  3420. this.myDelIds = [];
  3421. this.$nextTick(() => {
  3422. this.$refs.tableRef?.clearSelection();
  3423. });
  3424. } else {
  3425. this.$message.error(res.msg);
  3426. }
  3427. } catch (error) {}
  3428. },
  3429. // 发货回调
  3430. myDeliverHandler(row) {
  3431. this.currentRow = row;
  3432. this.deliverShow = true;
  3433. this.$nextTick(() => {
  3434. this.$refs.deliverRef.productInvoiceInfo(row);
  3435. });
  3436. },
  3437. },
  3438. };
  3439. </script>
  3440. <style scoped lang="scss">
  3441. ::v-deep .el-dialog:not(.is-fullscreen) {
  3442. min-width: 610px !important;
  3443. }
  3444. </style>