index.vue 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564
  1. <template>
  2. <div class="app-container">
  3. <el-dialog
  4. :title="upload.title"
  5. :visible.sync="upload.open"
  6. width="400px"
  7. append-to-body
  8. >
  9. <el-upload
  10. ref="upload"
  11. :limit="1"
  12. accept=".xlsx, .xls"
  13. :headers="upload.headers"
  14. :action="
  15. upload.url +
  16. '?updateSupport=' +
  17. upload.updateSupport +
  18. '&tableName=' +
  19. tableName +
  20. '&sqlKey=' +
  21. tableKey
  22. "
  23. v-loading="upload.isUploading"
  24. :disabled="upload.isUploading"
  25. :on-progress="handleFileUploadProgress"
  26. :on-success="handleFileSuccess"
  27. :auto-upload="false"
  28. :onChange="handleChange"
  29. drag
  30. >
  31. <i class="el-icon-upload"></i>
  32. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  33. <div class="el-upload__tip text-center" slot="tip">
  34. <!-- <div class="el-upload__tip" slot="tip">-->
  35. <!-- <el-checkbox v-model="upload.updateSupport"/>-->
  36. <!-- 是否更新已经存在的用户数据-->
  37. <!-- </div>-->
  38. <span>仅允许导入xls、xlsx格式文件。</span>
  39. <el-link
  40. type="primary"
  41. :underline="false"
  42. style="font-size: 12px; vertical-align: baseline"
  43. @click="importTemplate"
  44. >下载模板
  45. </el-link>
  46. </div>
  47. </el-upload>
  48. <div slot="footer" class="dialog-footer">
  49. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  50. <el-button @click="upload.open = false">取 消</el-button>
  51. </div>
  52. </el-dialog>
  53. <Queryfrom
  54. :form-vals="templateInfo.where"
  55. :statisticList="statisticList"
  56. :showCount="showCount"
  57. :showSearch="showSearch"
  58. @getList="getList"
  59. ref="mychild"
  60. />
  61. <el-row :gutter="10" class="mb8">
  62. <el-col :span="1.5">
  63. <el-button
  64. type="primary"
  65. plain
  66. icon="el-icon-plus"
  67. size="mini"
  68. @click="addHandler"
  69. >新增
  70. </el-button>
  71. </el-col>
  72. <!-- <el-col :span="1.5" v-if="false">
  73. <el-button
  74. type="success"
  75. plain
  76. icon="el-icon-edit"
  77. size="mini"
  78. :disabled="single"
  79. @click="handleUpdate"
  80. >修改
  81. </el-button>
  82. </el-col> -->
  83. <el-col :span="1.5">
  84. <el-button
  85. type="danger"
  86. plain
  87. icon="el-icon-delete"
  88. size="mini"
  89. :disabled="multiple"
  90. @click="batchDelete"
  91. >删除
  92. </el-button>
  93. </el-col>
  94. <el-col :span="1.5">
  95. <el-button
  96. plain
  97. icon="el-icon-upload2"
  98. size="mini"
  99. @click="upload.open = true"
  100. >导入
  101. </el-button>
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-button
  105. type="warning"
  106. plain
  107. icon="el-icon-download"
  108. size="mini"
  109. @click="handleExport"
  110. >导出
  111. </el-button>
  112. </el-col>
  113. <right-toolbar
  114. style="float: right"
  115. :showCount.sync="showCount"
  116. :showSearch.sync="showSearch"
  117. :counts="true"
  118. @queryTable="pageList"
  119. ></right-toolbar>
  120. <el-radio-group
  121. style="float: right; margin-right: 100px"
  122. v-model="orderType"
  123. size="mini"
  124. @change="orderTypeChange"
  125. >
  126. <el-radio-button :label="0">全部</el-radio-button>
  127. <el-radio-button :label="1">库存</el-radio-button>
  128. <el-radio-button :label="2">生产</el-radio-button>
  129. </el-radio-group>
  130. </el-row>
  131. <el-table
  132. v-loading="loading"
  133. :data="tableList"
  134. @selection-change="handleSelectionChange"
  135. ref="tableRef"
  136. :cell-style="cellStyle"
  137. :reserve-selection="true"
  138. :row-key="getRowKey"
  139. >
  140. <el-table-column
  141. type="selection"
  142. width="55"
  143. reserve-selection
  144. align="center"
  145. >
  146. </el-table-column>
  147. <!-- <span v-for="(key, val) in columns" :key="key">
  148. <el-table-column :label="key" align="center" :prop="val" />
  149. </span> -->
  150. <el-table-column
  151. v-for="item in columns"
  152. :key="item.key"
  153. :label="item.value"
  154. align="center"
  155. :prop="item.key"
  156. >
  157. <template slot-scope="scope">
  158. <!-- 存在字段样式或字典样式 -->
  159. <template
  160. v-if="
  161. scope.row.styleFieldObj != undefined &&
  162. scope.row.styleFieldObj[item.key]
  163. "
  164. >
  165. <!-- 字段样式 -->
  166. <template v-if="scope.row.styleFieldObj[item.key].styleType == 1">
  167. <!-- 一般字体样式 -->
  168. <template
  169. v-if="scope.row.styleFieldObj[item.key].fieldStyleType == 0"
  170. >
  171. <span
  172. :style="`color:${
  173. scope.row.styleFieldObj[item.key].fontColor
  174. }`"
  175. >{{ scope.row[item.key] }}</span
  176. >
  177. </template>
  178. <!-- 标签字体样式 -->
  179. <template
  180. v-else-if="
  181. scope.row.styleFieldObj[item.key].fieldStyleType == 1
  182. "
  183. >
  184. <el-tag
  185. :type="scope.row.styleFieldObj[item.key].tagType"
  186. :effect="
  187. scope.row.styleFieldObj[item.key].isTagFullBg
  188. ? 'dark'
  189. : 'light'
  190. "
  191. >
  192. {{ scope.row[item.key] }}
  193. </el-tag>
  194. </template>
  195. </template>
  196. <!-- 字典样式 -->
  197. <template
  198. v-else-if="scope.row.styleFieldObj[item.key].styleType == 2"
  199. >
  200. <span
  201. v-if="
  202. scope.row.styleFieldObj[item.key].listClass == '' ||
  203. scope.row.styleFieldObj[item.key].listClass == 'default'
  204. "
  205. >{{ scope.row.styleFieldObj[item.key].dictLabel }}</span
  206. >
  207. <el-tag
  208. v-else
  209. :type="
  210. scope.row.styleFieldObj[item.key].listClass == 'primary'
  211. ? ''
  212. : scope.row.styleFieldObj[item.key].listClass
  213. "
  214. >{{ scope.row.styleFieldObj[item.key].dictLabel }}</el-tag
  215. >
  216. </template>
  217. </template>
  218. <!-- 显示默认值 -->
  219. <template v-else>
  220. {{ scope.row[item.key] }}
  221. </template>
  222. </template>
  223. </el-table-column>
  224. <el-table-column
  225. v-if="isShowExcuteCol"
  226. label="操作"
  227. align="center"
  228. class-name="small-padding fixed-width"
  229. >
  230. <template slot-scope="scope">
  231. <!-- <el-button
  232. type="info"
  233. size="default"
  234. @click="handleEdit(scope.$index, scope.row)"
  235. >编辑</el-button
  236. > -->
  237. <Menu
  238. :row="scope.row"
  239. v-for="btnObj in excuteBtnArr"
  240. :key="btnObj.id"
  241. :listAll="btnObj"
  242. @excuteHandler="excuteHandler"
  243. ></Menu>
  244. </template>
  245. </el-table-column>
  246. </el-table>
  247. <pagination
  248. v-show="total > 0"
  249. :total="total"
  250. :page.sync="queryParams.pageNum"
  251. :limit.sync="queryParams.pageSize"
  252. @pagination="pageList"
  253. />
  254. <!-- k-form-build 组件渲染弹窗-->
  255. <el-dialog :title="title" :visible.sync="kOpen" append-to-body>
  256. <k-form-build
  257. v-if="jsonData"
  258. class="formBuild"
  259. ref="addFromRef"
  260. :dynamicData="dynamicData"
  261. :defaultValue="defaultValue"
  262. @submit="tempSubBtn"
  263. @change="formChangeHandler"
  264. :value="jsonData"
  265. />
  266. <div slot="footer" class="dialog-footer">
  267. <el-button type="primary" @click="editConfirmHandler">确 定</el-button>
  268. <el-button @click="kCancel">取 消</el-button>
  269. </div>
  270. </el-dialog>
  271. <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
  272. <el-dialog :title="title" :visible.sync="open" append-to-body>
  273. <!-- <iframe
  274. :src="iframeUrl"
  275. width="100%"
  276. height="600px"
  277. style="border: none"
  278. scrolling="no"
  279. >
  280. </iframe> -->
  281. <!-- <k-form-build
  282. v-if="jsonData"
  283. class="formBuild"
  284. ref="addFromRef"
  285. :dynamicData="dynamicData"
  286. :defaultValue="defaultValue"
  287. @submit="tempSubBtn"
  288. @change="formChangeHandler"
  289. :value="jsonData"
  290. /> -->
  291. <el-row :gutter="20">
  292. <el-form
  293. :model="formData"
  294. ref="formDataRef"
  295. :rules="rules"
  296. label-width="100px"
  297. :inline="true"
  298. size="normal"
  299. >
  300. <!-- <el-form-item prop="saleNo" label="合同号:">
  301. <el-input size="small" v-model="formData.saleNo"></el-input>
  302. </el-form-item> -->
  303. <el-col :span="12">
  304. <el-form-item prop="saleDate" label="日期:">
  305. <el-date-picker
  306. size="small"
  307. v-model="formData.saleDate"
  308. value-format="yyyy-MM-dd"
  309. format="yyyy-MM-dd"
  310. type="date"
  311. placeholder="选择日期"
  312. >
  313. </el-date-picker>
  314. </el-form-item>
  315. </el-col>
  316. <el-col :span="12">
  317. <el-form-item prop="saleCustomNo" label="客户名称:">
  318. <el-select
  319. size="small"
  320. v-model="formData.saleCustomNo"
  321. placeholder="请选择客户"
  322. clearable
  323. filterable
  324. @change="customChangeHandler"
  325. >
  326. <el-option
  327. v-for="item in customerOptions"
  328. :key="item.customNo"
  329. :label="item.customName"
  330. :value="item.customNo"
  331. >
  332. </el-option>
  333. </el-select>
  334. </el-form-item>
  335. </el-col>
  336. <el-col :span="12">
  337. <el-form-item label="联系人:" size="normal">
  338. {{ formData.contactPerson }}
  339. </el-form-item>
  340. <el-form-item label="客户地址:" size="normal">
  341. {{ formData.customAddress }}
  342. </el-form-item>
  343. <el-form-item label="客户国别:" size="normal">
  344. {{ formData.customCountryType }}
  345. </el-form-item>
  346. </el-col>
  347. <el-col :span="12">
  348. <el-form-item
  349. label-width="120px"
  350. prop="saleDate"
  351. label="预计下单时间:"
  352. >
  353. <el-date-picker
  354. size="small"
  355. v-model="formData.saleOrderEstimatedTime"
  356. value-format="yyyy-MM-dd"
  357. format="yyyy-MM-dd"
  358. type="date"
  359. placeholder="选择日期"
  360. >
  361. </el-date-picker>
  362. </el-form-item>
  363. </el-col>
  364. <el-col :span="12">
  365. <el-form-item label="交货周期:" size="normal" prop="saleLeadTime">
  366. <el-input size="small" v-model="formData.saleLeadTime"></el-input>
  367. </el-form-item>
  368. </el-col>
  369. <el-col :span="24">
  370. <el-divider>货品明细</el-divider>
  371. </el-col>
  372. <el-table
  373. :data="productionTableData"
  374. border
  375. show-summary
  376. :summary-method="getSummaries"
  377. sum-text="小计"
  378. style="width: 100%"
  379. >
  380. <el-table-column prop="productName" label="品名" width="180">
  381. <template slot-scope="scope">
  382. <!-- <el-input
  383. v-model="scope.row.productName"
  384. size="small"
  385. clearable
  386. ></el-input> -->
  387. <el-select
  388. v-model="scope.row.productNo"
  389. placeholder=""
  390. clearable
  391. filterable
  392. @change="handleProductChange(scope.row.productNo, scope.row)"
  393. >
  394. <el-option
  395. v-for="item in productionOptions"
  396. :key="item.productNo"
  397. :label="item.productName"
  398. :value="item.productNo"
  399. >
  400. </el-option>
  401. </el-select>
  402. </template>
  403. </el-table-column>
  404. <el-table-column prop="productNumber" label="数量/kg">
  405. <template slot-scope="scope">
  406. <el-input
  407. v-model="scope.row.productNumber"
  408. size="small"
  409. clearable
  410. @change="computedPrice(scope.row)"
  411. ></el-input>
  412. </template>
  413. </el-table-column>
  414. <el-table-column prop="productUnitPrice" label="单价">
  415. <template slot-scope="scope">
  416. <el-input
  417. v-model="scope.row.productUnitPrice"
  418. size="small"
  419. @change="computedPrice(scope.row)"
  420. clearable
  421. ></el-input>
  422. </template>
  423. </el-table-column>
  424. <el-table-column prop="productAmounts" label="金额">
  425. <template slot-scope="scope">
  426. <!-- <el-input
  427. v-model="scope.row.productAmounts"
  428. size="small"
  429. clearable
  430. ></el-input> -->
  431. {{ scope.row.productAmounts }}
  432. </template>
  433. </el-table-column>
  434. <el-table-column prop="remark" label="备注">
  435. <template slot-scope="scope">
  436. <el-input
  437. v-model="scope.row.remark"
  438. size="small"
  439. clearable
  440. ></el-input>
  441. </template>
  442. </el-table-column>
  443. <el-table-column label="操作">
  444. <template slot-scope="scope">
  445. <el-button
  446. type="danger"
  447. size="small"
  448. @click="deleteProduct(scope.$index)"
  449. >删除</el-button
  450. >
  451. </template>
  452. </el-table-column>
  453. </el-table>
  454. <el-button
  455. class="mt5"
  456. type="primary"
  457. style="width: 100%"
  458. size="small"
  459. @click="addProduct"
  460. >添加货品</el-button
  461. >
  462. <el-col :span="12">
  463. <el-form-item label-width="120px" label="合计金额(大写)">
  464. <el-input
  465. v-model="formData.saleAmountInWords"
  466. size="small"
  467. clearable
  468. ></el-input>
  469. </el-form-item>
  470. </el-col>
  471. <el-col :span="12">
  472. <el-form-item label="付款方式">
  473. <el-input
  474. v-model="formData.salePayType"
  475. size="small"
  476. clearable
  477. ></el-input>
  478. </el-form-item>
  479. </el-col>
  480. <el-col :span="24">
  481. <el-divider>工艺要求</el-divider>
  482. </el-col>
  483. <el-col :span="12">
  484. <el-form-item label="网格:">
  485. <el-input
  486. v-model="formData.craftGrid"
  487. size="small"
  488. clearable
  489. ></el-input>
  490. </el-form-item>
  491. </el-col>
  492. <el-col :span="12">
  493. <el-form-item label="油剂:">
  494. <el-input
  495. v-model="formData.craftOil"
  496. size="small"
  497. clearable
  498. ></el-input>
  499. </el-form-item>
  500. </el-col>
  501. <el-col :span="12">
  502. <el-form-item label="卷装:">
  503. <el-input
  504. v-model="formData.craftPackage"
  505. size="small"
  506. clearable
  507. ></el-input>
  508. </el-form-item>
  509. </el-col>
  510. <el-col :span="12">
  511. <el-form-item label="色牢度:">
  512. <el-input
  513. v-model="formData.craftColorFastness"
  514. size="small"
  515. clearable
  516. ></el-input>
  517. </el-form-item>
  518. </el-col>
  519. <el-col :span="12">
  520. <el-form-item label="其它:">
  521. <el-input
  522. v-model="formData.craftOther"
  523. size="small"
  524. clearable
  525. ></el-input>
  526. </el-form-item>
  527. </el-col>
  528. <el-col :span="12">
  529. <el-form-item label="包装/贴唛:">
  530. <el-input
  531. v-model="formData.craftMark"
  532. size="small"
  533. clearable
  534. ></el-input>
  535. </el-form-item>
  536. </el-col>
  537. <el-col :span="12">
  538. <el-form-item label="运输方式:">
  539. <el-input
  540. v-model="formData.shippingMethod"
  541. size="small"
  542. clearable
  543. ></el-input>
  544. </el-form-item>
  545. </el-col>
  546. <el-col :span="24">
  547. <el-divider>审计人员数据</el-divider>
  548. </el-col>
  549. <el-col :span="12">
  550. <el-form-item label="业务员:">
  551. <!-- <el-input
  552. v-model="formData.salesman"
  553. size="small"
  554. clearable
  555. ></el-input> -->
  556. {{ nickName }}
  557. </el-form-item>
  558. </el-col>
  559. </el-form>
  560. </el-row>
  561. <div slot="footer" class="dialog-footer">
  562. <el-button type="primary" @click="editConfirm">确 定</el-button>
  563. <el-button @click="cancel">取 消</el-button>
  564. </div>
  565. </el-dialog>
  566. <!-- 绑定按钮dialog -->
  567. <el-dialog
  568. title="提示"
  569. :visible.sync="btnDialogVisible"
  570. :before-close="handleClose"
  571. >
  572. <DialogTemplate
  573. ref="dialogRef"
  574. :groupKey="groupKey"
  575. :rowobj="rowobj"
  576. :subCount="subCount"
  577. :tableCount="tableCount"
  578. :subTableName="subTableName"
  579. @addList="addListHandler"
  580. >
  581. </DialogTemplate>
  582. <span slot="footer" class="dialog-footer">
  583. <el-button @click="btnDialogVisible = false">取 消</el-button>
  584. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  585. </span>
  586. </el-dialog>
  587. <!-- 自定义弹窗 -->
  588. <el-dialog
  589. title="提示"
  590. :visible.sync="btnDialogVisible"
  591. :before-close="handleClose"
  592. >
  593. <DialogTemplate
  594. ref="dialogRef"
  595. :groupKey="groupKey"
  596. :rowobj="rowobj"
  597. :subCount="subCount"
  598. :tableCount="tableCount"
  599. :subTableName="subTableName"
  600. @addList="addListHandler"
  601. >
  602. </DialogTemplate>
  603. <span slot="footer" class="dialog-footer">
  604. <el-button @click="btnDialogVisible = false">取 消</el-button>
  605. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  606. </span>
  607. </el-dialog>
  608. <!-- 详情弹窗 -->
  609. <el-dialog title="详情" :visible.sync="detailShow" width="1000px">
  610. <div ref="detailTable" id="detail"></div>
  611. <span slot="footer" class="dialog-footer">
  612. <el-button @click="detailShow = false">取 消</el-button>
  613. <el-button type="primary" @click="detailPrintHandler">打 印</el-button>
  614. </span>
  615. </el-dialog>
  616. <div id="printDom"></div>
  617. </div>
  618. </template>
  619. <script>
  620. import {
  621. delTableData,
  622. dragTableInfo,
  623. listTable,
  624. unionListTableData,
  625. getInfoBySqlKey,
  626. btnCommonApi,
  627. addTableData,
  628. batchEdit,
  629. getStatisticList,
  630. getTableList1,
  631. } from "@/api/tablelist/commonTable";
  632. import { listData } from "@/api/system/tenant/data";
  633. import { getToken } from "@/utils/auth";
  634. import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
  635. import { camelCase, toUnderline } from "@/utils";
  636. import { inputDisableComplete } from "@/utils/other";
  637. import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
  638. import { checkRole } from "@/utils/permission";
  639. import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
  640. import { queryDropDownBoxData } from "@/api/dragform/form";
  641. import { v4 as uuidv4 } from "uuid";
  642. import { mapState } from "vuex";
  643. import moment from "moment";
  644. export default {
  645. name: "listInfo",
  646. components: { Queryfrom, Menu, DialogTemplate },
  647. data() {
  648. return {
  649. // 详情弹窗数据
  650. detailShow: false,
  651. printDomData: "",
  652. // k-form-build组件渲染弹窗
  653. kOpen: false,
  654. // 新的自定义数据 start
  655. orderType: 0, //新的条件查询参数
  656. productIds: [], //货品Ids
  657. isEdit: false,
  658. formData: {
  659. //订单表数据
  660. saleNo: "", //合同号
  661. saleCustomNo: "", //客户编号
  662. saleDate: "", //销售单日期
  663. saleOrderEstimatedTime: "", //预计下单时间
  664. saleLeadTime: "", //交货周期
  665. saleAmounts: "", //合计金额 小写
  666. saleAmountInWords: "", //合计金额 大写
  667. salePayType: "", //支付方式
  668. salesman: "", //业务员
  669. saleLeader: "", //业务主管
  670. finance: "", //财务部
  671. production: "", //生产部
  672. saleApprover: "", //批准人
  673. customAddress: "", //客户地址
  674. customCountryType: "", //国家类型
  675. contactPerson: "", //联系人
  676. // 货品明细表数据
  677. productNo: "", //货品号
  678. productName: "", //货品名称
  679. productNumber: "", //销售数量
  680. productWeight: "", //销售重量kg
  681. productUnitPrice: "", //单价
  682. productAmounts: "", //金额
  683. remark: "", //备注
  684. // 工艺表
  685. craftGrid: "", //网格
  686. craftOil: "", //油剂
  687. craftPackage: "", //卷装
  688. craftColorFastness: "", //色牢度
  689. craftOther: "", //其它工艺要求
  690. craftMark: "", //包装/贴唛
  691. shippingMethod: "", //运输方式
  692. },
  693. productionOptions: [],
  694. customerOptions: [],
  695. productionTableData: [
  696. // {
  697. // productNo: "", //货品名称
  698. // productNumber: 2, //销售数量
  699. // productWeight: 1, //销售重量kg
  700. // productUnitPrice: 20, //单价
  701. // productAmounts: 20, //金额
  702. // remark: "", //备注
  703. // },
  704. ],
  705. rules: {
  706. saleDate: [
  707. {
  708. required: true,
  709. message: "请选择日期",
  710. trigger: "change",
  711. },
  712. ],
  713. saleCustomNo: [
  714. {
  715. required: true,
  716. message: "请选择客户",
  717. trigger: "change",
  718. },
  719. ],
  720. saleDate: [
  721. {
  722. required: true,
  723. message: "请选择预计下单时间",
  724. trigger: "change",
  725. },
  726. ],
  727. saleLeadTime: [
  728. {
  729. required: true,
  730. message: "请输入交货周期",
  731. trigger: "blur",
  732. },
  733. ],
  734. },
  735. // end
  736. // 绑定按钮dialog
  737. btnDialogVisible: false,
  738. // 绑定修改dialog
  739. groupKey: "",
  740. // 遮罩层
  741. loading: true,
  742. // 选中数组
  743. ids: [],
  744. // 非单个禁用
  745. single: true,
  746. // 非多个禁用
  747. multiple: true,
  748. // 显示统计
  749. showCount: true,
  750. // 显示搜索条件
  751. showSearch: true,
  752. // 总条数
  753. total: 0,
  754. // 用户表格数据
  755. tableList: [],
  756. // 弹出层标题
  757. title: "",
  758. // 日期范围
  759. dateRange: [],
  760. // 表单参数
  761. form: {},
  762. // cru 弹窗
  763. open: false,
  764. // excel共通导入数据
  765. upload: {
  766. // 是否显示弹出层
  767. open: false,
  768. // 弹出层标题(
  769. title: "",
  770. // 是否禁用上传
  771. isUploading: false,
  772. // 是否更新已经存在的数据
  773. updateSupport: 0,
  774. // 设置上传的请求头部
  775. headers: { Authorization: "Bearer " + getToken() },
  776. // 上传的地址
  777. url: process.env.VUE_APP_BASE_API1 + "common/uploadData",
  778. },
  779. // 排序方式 默认降序
  780. sortOrder: true,
  781. // 共通查询参数接受子组件的参数
  782. queryParams: {
  783. pageNum: 1, // 第几页
  784. pageSize: 10, // 每页大小
  785. orderByColumn: "", // 根据某列排序
  786. isAsc: "", // desc(降序)或 asc(升序)
  787. saleOrderOrderType: "",
  788. // 基本查询参数
  789. basicMap: {
  790. tableName: "drag_form",
  791. },
  792. // 当前表字段筛选参数
  793. queryMap: {
  794. // 当前查询基本参数
  795. // ... key : value 当前页面的筛选条件
  796. // 超级查询的唯一值
  797. queryCriteriaValue: "",
  798. },
  799. },
  800. // 列信息
  801. columns: {},
  802. // 当前模版信息
  803. templateInfo: {},
  804. // 查询条件
  805. queryFromWhere: {},
  806. // 当前table唯一标识
  807. tableKey: null,
  808. // 当前表名称
  809. tableName: null,
  810. //存放html代码块
  811. iframeUrl: "",
  812. //存放表单渲染数据
  813. jsonData: {},
  814. // 回显表格数据,
  815. defaultValue: {},
  816. // 统计card
  817. statisticList: [],
  818. // 样式表
  819. styleList: [],
  820. // 字典样式对象
  821. dictStyleObj: {},
  822. // 操作列 按钮数据
  823. excuteBtnArr: [],
  824. // 下拉框动态数据
  825. dynamicData: {},
  826. // 当前点击按钮的数据
  827. currentBtnData: {},
  828. // 修改选中行
  829. rowobj: {},
  830. // 该行的统计信息
  831. subCount: [],
  832. tableCount: [],
  833. // 弹窗新增数据
  834. addLists: [],
  835. subTableName: "",
  836. // 当前点击行的数据
  837. currentRow: {},
  838. };
  839. },
  840. created() {
  841. // 得到当前展示的table的唯一标识
  842. this.tableKey = this.$route.query.tableKey;
  843. },
  844. watch: {},
  845. async mounted() {
  846. await this.getDropDownData();
  847. },
  848. computed: {
  849. isShowExcuteCol() {
  850. return !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
  851. },
  852. ...mapState({
  853. nickName: (state) => state.user.nickName,
  854. }),
  855. },
  856. methods: {
  857. // 产品名称改变
  858. handleProductChange(productNo, row) {
  859. if (!productNo) {
  860. return;
  861. }
  862. row.productName = this.productionOptions.find(
  863. (item) => item.productNo == productNo
  864. )?.productName;
  865. },
  866. // 订单类型改变回调
  867. orderTypeChange(type) {
  868. this.getList(false, type);
  869. },
  870. // 重置审计表单数据
  871. resetFormData() {
  872. Object.assign(this.formData, {
  873. //订单表数据
  874. saleNo: "", //合同号
  875. saleCustomNo: "", //客户编号
  876. saleDate: "", //销售单日期
  877. saleOrderEstimatedTime: "", //预计下单时间
  878. saleLeadTime: "", //交货周期
  879. saleAmounts: "", //合计金额 小写
  880. saleAmountInWords: "", //合计金额 大写
  881. salePayType: "", //支付方式
  882. salesman: "", //业务员
  883. saleLeader: "", //业务主管
  884. finance: "", //财务部
  885. production: "", //生产部
  886. saleApprover: "", //批准人
  887. customAddress: "", //客户地址
  888. customCountryType: "", //国家类型
  889. contactPerson: "", //联系人
  890. // 货品明细表数据
  891. productNo: "", //货品号
  892. productName: "", //货品名称
  893. productNumber: "", //销售数量
  894. productWeight: "", //销售重量kg
  895. productUnitPrice: "", //单价
  896. productAmounts: "", //金额
  897. remark: "", //备注
  898. // 工艺表
  899. craftGrid: "", //网格
  900. craftOil: "", //油剂
  901. craftPackage: "", //卷装
  902. craftColorFastness: "", //色牢度
  903. craftOther: "", //其它工艺要求
  904. craftMark: "", //包装/贴唛
  905. shippingMethod: "", //运输方式
  906. });
  907. this.productionTableData = [];
  908. },
  909. // 自定义的小计计算方法
  910. getSummaries(param) {
  911. const { columns, data } = param;
  912. console.log(columns, data);
  913. const sums = [];
  914. columns.forEach((column, index) => {
  915. if (index === 0) {
  916. sums[index] = "小计";
  917. return;
  918. }
  919. const values = data.map((item) => Number(item[column.property]));
  920. if (index === 4 || index === 5) {
  921. sums[index] = "";
  922. } else if (!values.every((value) => isNaN(value))) {
  923. sums[index] = values.reduce((prev, curr) => {
  924. const value = Number(curr);
  925. if (!isNaN(value)) {
  926. return prev + curr;
  927. } else {
  928. return prev;
  929. }
  930. }, 0);
  931. sums[index];
  932. } else {
  933. sums[index] = "N/A";
  934. }
  935. });
  936. return sums;
  937. },
  938. // 货品表格数据删除回调
  939. deleteProduct(index) {
  940. this.productionTableData.splice(index, 1);
  941. },
  942. // 货品表格数据新增回调
  943. addProduct() {
  944. this.productionTableData.push({
  945. saleProductNo: uuidv4(),
  946. productNo: "", //货品编号
  947. productName: "", //货品名称
  948. productNumber: "", //销售数量
  949. productWeight: "", //销售重量kg
  950. productUnitPrice: "", //单价
  951. productAmounts: "", //金额
  952. remark: "", //备注
  953. });
  954. },
  955. // 客户名称改变回调
  956. customChangeHandler(val) {
  957. // if (!val) return;
  958. let customData = this.customerOptions.find(
  959. (item) => item.customNo == val
  960. );
  961. this.formData.customAddress = customData?.customAddress || "无";
  962. this.formData.customCountryType = customData?.customCountryType || "无";
  963. this.formData.contactPerson = customData?.contactPerson || "无";
  964. },
  965. //审计新增
  966. async addHandler() {
  967. this.isEdit = false;
  968. await this.getDropDownData();
  969. this.resetFormData();
  970. this.title = "新增审计单";
  971. this.open = true;
  972. },
  973. // 获取下拉框数据
  974. async getDropDownData() {
  975. try {
  976. let payLoad = [
  977. {
  978. basicMap: {
  979. tableName: "production",
  980. },
  981. },
  982. {
  983. basicMap: {
  984. tableName: "customer",
  985. },
  986. },
  987. ];
  988. let res = await queryDropDownBoxData(payLoad);
  989. if (res.code == 200) {
  990. let { production, customer } = res.data.resultMap;
  991. this.productionOptions = production || [];
  992. this.customerOptions = customer || [];
  993. } else {
  994. throw Error("获取下拉框数据失败");
  995. }
  996. } catch (error) {
  997. console.log(error);
  998. }
  999. },
  1000. // 获取row-key
  1001. getRowKey(row) {
  1002. return row[
  1003. camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
  1004. ];
  1005. },
  1006. /** 查询列表 */
  1007. getList(queryParams, orderType = 0) {
  1008. this.loading = true;
  1009. // 序列化当前查询参数列表
  1010. queryParams && (this.queryParams.queryMap = queryParams.queryMap);
  1011. // 获取当前表单结构信息
  1012. dragTableInfo({ queryMap: { tableKey: this.tableKey } })
  1013. .then((res) => {
  1014. // 得到当前模版信息 --- sql columns queryWhere
  1015. this.templateInfo = res.data.resultMap;
  1016. this.styleList = res.data.resultMap.style?.map((item) => {
  1017. item.styleField = camelCase(
  1018. item.styleField.replace(".", "_") || ""
  1019. );
  1020. return item;
  1021. });
  1022. // 获取操作列的按钮数据
  1023. this.excuteBtnArr = res.data.resultMap.button;
  1024. console.log(this.excuteBtnArr);
  1025. this.excuteBtnArr[0].children.push(
  1026. {
  1027. btnName: "编辑",
  1028. btnType: "myEdit",
  1029. btnIcon: "",
  1030. btnShowCondition: "",
  1031. children: [],
  1032. },
  1033. {
  1034. btnName: "详情",
  1035. btnType: "myDetail",
  1036. btnIcon: "",
  1037. btnShowCondition: "",
  1038. children: [],
  1039. }
  1040. );
  1041. this.queryParams.orderByColumn =
  1042. res.data.resultMap.querySql.orderByColumn;
  1043. this.sortOrder = JSON.parse(res.data.resultMap.querySql.sortOrder);
  1044. // 根据拖拽时设置当前列表排列顺序
  1045. this.queryParams.isAsc = this.sortOrder ? "DESC" : "ASC";
  1046. this.tableName = this.templateInfo.template.dtTableName;
  1047. // 得到查询条件
  1048. this.queryFromWhere = res.data.resultMap.where;
  1049. // 得到当前列表信息
  1050. this.columns = this.columnsHandler(
  1051. JSON.parse(this.templateInfo.template.dtColumnName)
  1052. );
  1053. })
  1054. .finally((fes) => {
  1055. if (this.templateInfo == {}) return;
  1056. // 调用查询需要携带当前table的唯一标识
  1057. this.queryParams.queryMap.sqlkey = this.templateInfo.template.sqlKey;
  1058. this.queryParams.orderByColumn = camelCase(
  1059. this.queryParams.orderByColumn || ""
  1060. );
  1061. // 根据sql语句查询当前表数据
  1062. let getListFun = orderType == 0 ? unionListTableData : getTableList1;
  1063. if (orderType != 0) {
  1064. this.queryParams.conditionMap = {
  1065. columnName: "order_type",
  1066. columnValue: orderType,
  1067. };
  1068. }
  1069. getListFun(this.queryParams).then(async (res) => {
  1070. this.tableList = [];
  1071. res.rows.forEach((item) => {
  1072. this.tableList.push(item.resultMap);
  1073. });
  1074. // 驼峰转换
  1075. let tempTableList = [];
  1076. tempTableList = this.tableList.map((item) => {
  1077. let kv = {};
  1078. for (let itemKey in item) {
  1079. kv[camelCase(itemKey)] = item[itemKey];
  1080. }
  1081. return kv;
  1082. });
  1083. // this.setDictStyleData().then(() => {
  1084. // this.tableList = this.setFieldStyleData(this.tableList);
  1085. // });
  1086. this.tableList = await this.setFieldStyleData(tempTableList);
  1087. this.total = res.total;
  1088. // this.$nextTick(() => {
  1089. // this.$refs.tableRef?.clearSelection();
  1090. // });
  1091. this.loading = false;
  1092. });
  1093. // 查询统计信息
  1094. getStatisticList({
  1095. queryMap: {
  1096. tableKey: this.templateInfo.template.tableKey,
  1097. queryCriteriaValue: this.queryParams.queryMap.queryCriteriaValue,
  1098. },
  1099. }).then((res) => {
  1100. this.statisticList = res.data;
  1101. });
  1102. });
  1103. },
  1104. // 审计 提交编辑结果按钮回调
  1105. async editConfirm() {
  1106. this.$refs.formDataRef.validate(async (valid) => {
  1107. if (valid) {
  1108. let {
  1109. //订单表数据
  1110. saleCustomNo,
  1111. saleDate,
  1112. saleOrderEstimatedTime,
  1113. saleLeadTime,
  1114. saleAmounts,
  1115. saleAmountInWords,
  1116. salePayType,
  1117. salesman,
  1118. saleLeader,
  1119. finance,
  1120. production,
  1121. saleApprover,
  1122. // 工艺表数据
  1123. craftGrid,
  1124. craftOil,
  1125. craftPackage,
  1126. craftColorFastness,
  1127. craftOther,
  1128. craftMark,
  1129. shippingMethod,
  1130. } = this.formData;
  1131. let saleCraftNo = this.isEdit ? this.formData.saleCraftNo : uuidv4(),
  1132. saleNo = this.isEdit ? this.formData.saleNo : uuidv4();
  1133. let saleProductsNo = this.productionTableData
  1134. .map((item) => item.saleProductNo)
  1135. .join(","); //销售单表sale_products_no字段存货品表的sale_product_no,逗号分割
  1136. let saleValue = {
  1137. status: 1, //新增销售单时 默认为1
  1138. saleNo,
  1139. saleProductsNo,
  1140. saleOrderTechnologyNo: saleCraftNo,
  1141. saleCustomNo,
  1142. saleDate: moment(new Date(saleDate)).format("YYYY-MM-DD"),
  1143. saleOrderEstimatedTime: moment(
  1144. new Date(saleOrderEstimatedTime)
  1145. ).format("YYYY-MM-DD"),
  1146. saleLeadTime,
  1147. // saleAmounts, //合计金额 小写
  1148. saleAmountInWords,
  1149. salePayType,
  1150. salesman: this.nickName,
  1151. saleLeader,
  1152. finance,
  1153. production,
  1154. saleApprover,
  1155. };
  1156. let craftValue = {
  1157. saleOrderNo: saleNo,
  1158. saleCraftNo,
  1159. craftGrid,
  1160. craftOil,
  1161. craftPackage,
  1162. craftColorFastness,
  1163. craftOther,
  1164. craftMark,
  1165. shippingMethod,
  1166. };
  1167. let saleData = {
  1168. //订单表新增数据
  1169. basicMap: {
  1170. tableName: "sale_order",
  1171. },
  1172. // addListMap: [saleValue],
  1173. conditionMap: {},
  1174. commMap: {},
  1175. btnParametersMap: {},
  1176. };
  1177. let craftData = {
  1178. //工艺表新增数据
  1179. basicMap: {
  1180. tableName: "sale_craft",
  1181. },
  1182. // addListMap: [craftValue],
  1183. conditionMap: {},
  1184. commMap: {},
  1185. btnParametersMap: {},
  1186. };
  1187. this.productionTableData.forEach((item) => {
  1188. item.saleOrderNo = saleNo;
  1189. delete item.id;
  1190. delete item.productNotes;
  1191. delete item.updateBy;
  1192. delete item.updateById;
  1193. delete item.updateTime;
  1194. delete item.createBy;
  1195. delete item.createTime;
  1196. delete item.createById;
  1197. delete item.delFlag;
  1198. });
  1199. let productData = {
  1200. //货品表新增数据
  1201. basicMap: {
  1202. tableName: "sale_products",
  1203. },
  1204. addListMap: [...this.productionTableData],
  1205. conditionMap: {},
  1206. commMap: {},
  1207. btnParametersMap: {},
  1208. };
  1209. if (this.isEdit) {
  1210. //修改
  1211. Object.keys(saleValue).map((k) => {
  1212. saleData.commMap[k] = saleValue[k];
  1213. });
  1214. Object.keys(craftValue).map((k) => {
  1215. craftData.commMap[k] = craftValue[k];
  1216. });
  1217. saleData.conditionMap.saleNo = saleValue.saleNo;
  1218. craftData.conditionMap.saleCraftNo = craftValue.saleCraftNo;
  1219. // for(let i = 0;i<this.)
  1220. let deletPayload = {
  1221. //删除货品数据的接口
  1222. basicMap: {
  1223. tableName: "sale_products",
  1224. },
  1225. conditionMap: {
  1226. saleProductNo: this.productIds,
  1227. },
  1228. };
  1229. let delRes = { code: 200 };
  1230. if (this.productIds.length) {
  1231. delRes = await delTableData(deletPayload); //删除旧数据
  1232. }
  1233. let updateSaleRes = await batchEdit(saleData);
  1234. let updateCraftRes = await batchEdit(craftData);
  1235. let addProductRes = { code: 200 };
  1236. if (productData.addListMap.length) {
  1237. addProductRes = await addTableData(productData);
  1238. }
  1239. console.log(delRes, updateSaleRes, updateCraftRes, addProductRes);
  1240. if (
  1241. delRes?.code === 200 &&
  1242. updateSaleRes?.code === 200 &&
  1243. updateCraftRes?.code === 200 &&
  1244. addProductRes?.code === 200
  1245. ) {
  1246. this.$message.success("修改成功");
  1247. this.open = false;
  1248. this.getList();
  1249. } else {
  1250. this.$message.error("修改失败");
  1251. }
  1252. } else {
  1253. //新增
  1254. saleData.addListMap = [saleValue];
  1255. craftData.addListMap = [craftValue];
  1256. let saleRes = await addTableData(saleData);
  1257. let craftRes = await addTableData(craftData);
  1258. let productRes = { code: 200 };
  1259. if (productData.addListMap.length) {
  1260. productRes = await addTableData(productData);
  1261. }
  1262. if (
  1263. saleRes.code === 200 &&
  1264. craftRes.code === 200 &&
  1265. productRes.code === 200
  1266. ) {
  1267. this.$message.success("添加成功");
  1268. this.open = false;
  1269. this.getList();
  1270. } else {
  1271. this.$message.error("添加失败");
  1272. }
  1273. }
  1274. // Object.keys(saleValue).map((k) => {
  1275. // saleData.commMap[k] = saleValue[k];
  1276. // });
  1277. }
  1278. });
  1279. },
  1280. // 审计 编辑回调
  1281. async handleEdit(index, row) {
  1282. console.log(row);
  1283. let { saleOrderSaleNo } = row;
  1284. try {
  1285. let payLoad = [
  1286. {
  1287. basicMap: {
  1288. tableName: "sale_order",
  1289. },
  1290. conditionMap: {
  1291. sale_no: [saleOrderSaleNo],
  1292. },
  1293. },
  1294. {
  1295. basicMap: {
  1296. tableName: "sale_products",
  1297. },
  1298. conditionMap: {
  1299. sale_order_no: [saleOrderSaleNo],
  1300. },
  1301. },
  1302. {
  1303. basicMap: {
  1304. tableName: "sale_craft",
  1305. },
  1306. conditionMap: {
  1307. sale_order_no: [saleOrderSaleNo],
  1308. },
  1309. },
  1310. ];
  1311. let res = await queryDropDownBoxData(payLoad);
  1312. if (res.code == 200) {
  1313. this.isEdit = true;
  1314. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  1315. Object.assign(this.formData, {
  1316. ...sale_craft[0],
  1317. ...sale_order[0],
  1318. });
  1319. let { saleDate, saleOrderEstimatedTime } = sale_order[0];
  1320. saleDate && (this.formData.saleDate = new Date(saleDate));
  1321. saleOrderEstimatedTime &&
  1322. (this.formData.saleOrderEstimatedTime = saleOrderEstimatedTime);
  1323. this.productionTableData = sale_products;
  1324. this.productIds = sale_products.map((item) => item.saleProductNo);
  1325. await this.getDropDownData();
  1326. if (this.formData.saleCustomNo) {
  1327. this.customChangeHandler(this.formData.saleCustomNo);
  1328. }
  1329. this.title = "编辑审计单";
  1330. this.open = true;
  1331. }
  1332. } catch (error) {
  1333. console.log(error);
  1334. }
  1335. },
  1336. // 审计 批量删除回调
  1337. async batchDelete() {
  1338. if (!this.ids.length) return;
  1339. try {
  1340. await this.$confirm("是否确认删除选中的数据?", "警告", {
  1341. confirmButtonText: "确定",
  1342. cancelButtonText: "取消",
  1343. type: "warning",
  1344. });
  1345. let orderPayload = {
  1346. basicMap: {
  1347. tableName: "sale_order",
  1348. },
  1349. conditionMap: {
  1350. saleNo: this.ids,
  1351. },
  1352. };
  1353. let productsPayload = {
  1354. basicMap: {
  1355. tableName: "sale_products",
  1356. },
  1357. conditionMap: {
  1358. saleOrderNo: this.ids,
  1359. },
  1360. };
  1361. let craftPayload = {
  1362. basicMap: {
  1363. tableName: "sale_craft",
  1364. },
  1365. conditionMap: {
  1366. saleOrderNo: this.ids,
  1367. },
  1368. };
  1369. let orderRes = await delTableData(orderPayload);
  1370. // let productRes = await delTableData(productsPayload);
  1371. // let craftRes = await delTableData(craftPayload);
  1372. if (orderRes.code == 200) {
  1373. this.$message.success("删除成功");
  1374. this.getList();
  1375. } else {
  1376. this.$message.error("删除失败");
  1377. throw Error("删除失败");
  1378. }
  1379. this.ids = [];
  1380. this.$refs.tableRef.clearSelection();
  1381. } catch (error) {
  1382. console.log(error);
  1383. }
  1384. },
  1385. // 计算金额
  1386. computedPrice(row) {
  1387. let { productNumber, productUnitPrice } = row;
  1388. row.productAmounts = Number(productNumber) * Number(productUnitPrice);
  1389. },
  1390. isUpperCase(char) {
  1391. return char === char.toUpperCase();
  1392. },
  1393. // 下划线命名转驼峰命名
  1394. toUnderScoreCase(str) {
  1395. if (str === null) {
  1396. return null;
  1397. }
  1398. let sb = "";
  1399. // 前置字符是否大写
  1400. let preCharIsUpperCase = true;
  1401. // 当前字符是否大写
  1402. let curreCharIsUpperCase = true;
  1403. // 下一字符是否大写
  1404. let nexteCharIsUpperCase = true;
  1405. for (let i = 0; i < str.length; i++) {
  1406. let c = str.charAt(i);
  1407. if (i > 0) {
  1408. preCharIsUpperCase = isUpperCase(str.charAt(i - 1));
  1409. } else {
  1410. preCharIsUpperCase = false;
  1411. }
  1412. curreCharIsUpperCase = isUpperCase(c);
  1413. if (i < str.length - 1) {
  1414. nexteCharIsUpperCase = isUpperCase(str.charAt(i + 1));
  1415. }
  1416. if (
  1417. preCharIsUpperCase &&
  1418. curreCharIsUpperCase &&
  1419. !nexteCharIsUpperCase
  1420. ) {
  1421. sb += SEPARATOR;
  1422. } else if (i !== 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
  1423. sb += SEPARATOR;
  1424. }
  1425. sb += c.toLowerCase();
  1426. }
  1427. return sb;
  1428. },
  1429. // 处理列表信息
  1430. columnsHandler(columns) {
  1431. let resArr = [];
  1432. columns.forEach((item) => {
  1433. for (const key in item) {
  1434. let tempObj = {};
  1435. tempObj.key = camelCase(key);
  1436. tempObj.value = item[key];
  1437. resArr.push(tempObj);
  1438. }
  1439. });
  1440. return resArr;
  1441. },
  1442. // 取消按钮
  1443. cancel() {
  1444. this.open = false;
  1445. // this.reset();
  1446. },
  1447. // k-form-build 取消按钮
  1448. kCancel() {
  1449. this.kOpen = false;
  1450. // this.reset();
  1451. },
  1452. // 分页查询
  1453. pageList(row) {
  1454. // 调用子组件-》携带子组件参数请求后台
  1455. this.$refs.mychild.pageList(
  1456. row == undefined
  1457. ? {
  1458. limit: this.queryParams.pageSize,
  1459. page: this.queryParams.pageNum,
  1460. }
  1461. : row
  1462. );
  1463. },
  1464. // 多选框选中数据
  1465. handleSelectionChange(selection) {
  1466. // this.ids = selection.map(
  1467. // (item) =>
  1468. // item[
  1469. // camelCase(
  1470. // this.tableName + "_" + this.templateInfo.template?.primaryKey
  1471. // )
  1472. // ]
  1473. // );
  1474. this.ids = selection.map((item) => item.saleOrderSaleNo);
  1475. this.single = selection.length != 1;
  1476. this.multiple = !selection.length;
  1477. },
  1478. // 更多操作触发
  1479. handleCommand(command, row) {
  1480. switch (command) {
  1481. case "handleResetPwd":
  1482. this.handleResetPwd(row);
  1483. break;
  1484. case "handleAuthRole":
  1485. this.handleAuthRole(row);
  1486. break;
  1487. default:
  1488. break;
  1489. }
  1490. },
  1491. /** 新增按钮操作 */
  1492. handleAdd(row) {
  1493. // this.reset();
  1494. this.defaultValue = {};
  1495. getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1496. if (!data || !data.dfVueTemplate) {
  1497. this.jsonData = false;
  1498. this.$message.error("当前表格未绑定表单!");
  1499. return;
  1500. }
  1501. if (data.dfFormSql) {
  1502. let dynamicData = JSON.parse(data.dfFormSql);
  1503. Object.assign(this.dynamicData, dynamicData);
  1504. }
  1505. this.jsonData = JSON.parse(data.dfVueTemplate);
  1506. this.open = true;
  1507. this.title = "添加信息";
  1508. this.form.password = this.initPassword;
  1509. this.$nextTick(() => {
  1510. this.$refs.addFromRef.reset();
  1511. inputDisableComplete();
  1512. });
  1513. });
  1514. },
  1515. longestCommonSubstring(strs) {
  1516. if (!strs || strs.includes("")) return "";
  1517. let str1_Length = strs[0].length;
  1518. let str_Nums = strs.length;
  1519. let flag = 0;
  1520. for (let i = 0; i < str1_Length && flag == 0; i++) {
  1521. let char = strs[0][i];
  1522. for (var j = 1; j < str_Nums; j++) {
  1523. if (char !== strs[j][i] || i == strs[j].length) {
  1524. return strs[1].substring(0, i);
  1525. }
  1526. }
  1527. }
  1528. return strs[0];
  1529. },
  1530. // 绑定dialog对话框关闭
  1531. handleClose() {
  1532. this.btnDialogVisible = false;
  1533. },
  1534. getLastUppercaseWord(text) {
  1535. const pattern = /\b[A-Z][a-z]*\b/g;
  1536. const matches = [...text.matchAll(pattern)];
  1537. if (matches.length > 0) {
  1538. const lastMatch = matches[matches.length - 1][0];
  1539. return lastMatch;
  1540. } else {
  1541. return null;
  1542. }
  1543. },
  1544. /** 修改按钮操作 */
  1545. async handleUpdate(row, btnData) {
  1546. let nameTable = this.templateInfo.template.dtTableName;
  1547. this.rowobj = {};
  1548. let obj = {};
  1549. for (let key in row) {
  1550. let modifiedTable = key
  1551. .replace(/[A-Z]/g, (match) => `_${match}`)
  1552. .toLowerCase();
  1553. this.rowobj[modifiedTable] = row[key];
  1554. let str = modifiedTable.substring(nameTable.length + 1);
  1555. obj[str] = row[key];
  1556. }
  1557. // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1558. // if (!data || !data.dfVueTemplate) {
  1559. // this.$message.error("当前表格未绑定表单!");
  1560. // return;
  1561. // }});
  1562. // 新的修改请求
  1563. try {
  1564. let payLoad = {
  1565. basicMap: {
  1566. btnType: this.currentBtnData.btnType,
  1567. btnKey: this.currentBtnData.btnKey,
  1568. visible: "false",
  1569. sqlKey: this.templateInfo.template.sqlKey,
  1570. tableName: this.tableName,
  1571. },
  1572. conditionMap: {},
  1573. };
  1574. let primary = camelCase(
  1575. this.tableName + "_" + this.templateInfo.template?.primaryKey
  1576. );
  1577. payLoad.conditionMap[this.templateInfo.template?.primaryKey] =
  1578. row[primary];
  1579. let res = await btnCommonApi(payLoad);
  1580. // 判断是否绑定dialog弹窗
  1581. if (!this.currentBtnData.btnTableFormGroupKey) {
  1582. if (!res.data || !res.data.template) {
  1583. this.$message.error("当前按钮未绑定表单!");
  1584. return;
  1585. }
  1586. res.data.template.dfFormSql &&
  1587. (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
  1588. this.addRealFieldName(res.data.result.resultMap);
  1589. let resultMap = res.data.result.resultMap;
  1590. Object.assign(this.defaultValue, resultMap);
  1591. this.jsonData = JSON.parse(res.data.template.dfVueTemplate);
  1592. this.kOpen = true;
  1593. this.title = "修改信息";
  1594. this.form.password = this.initPassword;
  1595. this.$nextTick(() => {
  1596. this.$refs.addFromRef.setData(res.data.result.resultMap);
  1597. });
  1598. } else {
  1599. this.subTableName = res.data.result.dragTables[1].dtTableName;
  1600. this.btnDialogVisible = true;
  1601. this.groupKey = this.currentBtnData.btnTableFormGroupKey;
  1602. this.$nextTick(() => {
  1603. let refChild = this.$refs.dialogRef;
  1604. refChild.getLists(this.groupKey);
  1605. });
  1606. let tablesubKey = res.data.result.dragTables[1].tableKey;
  1607. // 查询统计信息
  1608. getStatisticList({
  1609. queryMap: {
  1610. tableKey: tablesubKey,
  1611. },
  1612. }).then((res) => {
  1613. this.subCount = res.data;
  1614. });
  1615. let prmKey = this.templateInfo.template.primaryKey;
  1616. let pkey = prmKey.replace(/_([a-z])/g, (match, p1) =>
  1617. p1.toUpperCase()
  1618. );
  1619. let data = {
  1620. queryMap: {
  1621. tableKey: res.data.result.dragTables[2].tableKey,
  1622. },
  1623. };
  1624. let key =
  1625. "#{" +
  1626. this.templateInfo.template.dtTableName +
  1627. "." +
  1628. this.templateInfo.template.primaryKey;
  1629. data.queryMap[key] =
  1630. "'" + obj[this.templateInfo.template.primaryKey] + "'";
  1631. getStatisticList(data).then((res) => {
  1632. this.tableCount = res.data;
  1633. });
  1634. }
  1635. // let fieldList = Object.keys(resultMap);
  1636. // let tableName = this.longestCommonSubstring(fieldList);
  1637. // fieldList.forEach((field) => {
  1638. // let realField = field.replace(tableName, "");
  1639. // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1640. // resultMap[realField] = resultMap[field];
  1641. // });
  1642. } catch (error) {
  1643. this.$message.error("网络异常,请稍后再试");
  1644. console.log(error);
  1645. }
  1646. return;
  1647. // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1648. // if (!data || !data.dfVueTemplate) {
  1649. // this.$message.error("当前表格未绑定表单!");
  1650. // return;
  1651. // }
  1652. // // let fieldList = Object.keys(row);
  1653. // // let tableName = this.longestCommonSubstring(fieldList);
  1654. // // fieldList.forEach((field) => {
  1655. // // let realField = field.replace(tableName, "");
  1656. // // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1657. // // row[realField] = row[field];
  1658. // // });
  1659. // this.addRealFieldName(row);
  1660. // Object.assign(this.defaultValue, row);
  1661. // this.jsonData = JSON.parse(data.dfVueTemplate);
  1662. // this.open = true;
  1663. // this.title = "修改信息";
  1664. // this.form.password = this.initPassword;
  1665. // this.$nextTick(() => {
  1666. // this.$refs.addFromRef.setData(row);
  1667. // });
  1668. // });
  1669. // return;
  1670. this.reset();
  1671. const userId = row.userId || this.ids;
  1672. getUser(userId).then((response) => {
  1673. this.form = response.data;
  1674. this.postOptions = response.posts;
  1675. this.roleOptions = response.roles;
  1676. this.$set(this.form, "postIds", response.postIds);
  1677. this.$set(this.form, "roleIds", response.roleIds);
  1678. this.open = true;
  1679. this.title = "修改当前信息";
  1680. this.form.password = "";
  1681. });
  1682. },
  1683. // 添加真正的字段名
  1684. addRealFieldName(row) {
  1685. let fieldList = Object.keys(row);
  1686. // let tableName = this.longestCommonSubstring(fieldList);
  1687. let tableName = camelCase(this.tableName);
  1688. fieldList.forEach((field) => {
  1689. let realField = field.replace(tableName, "");
  1690. realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1691. row[realField] = row[field];
  1692. });
  1693. },
  1694. /** 提交按钮 */
  1695. submitForm: function () {
  1696. this.$refs["form"].validate((valid) => {
  1697. if (valid) {
  1698. if (this.form.userId != undefined) {
  1699. updateUser(this.form).then((response) => {
  1700. this.$modal.msgSuccess("修改成功");
  1701. this.open = false;
  1702. this.getList();
  1703. });
  1704. } else {
  1705. addUser(this.form).then((response) => {
  1706. this.$modal.msgSuccess("新增成功");
  1707. this.open = false;
  1708. this.getList();
  1709. });
  1710. }
  1711. }
  1712. });
  1713. },
  1714. /** 删除按钮操作
  1715. *
  1716. * 删除提示信息语句(标识)
  1717. * */
  1718. handleDelete(row, btnData) {
  1719. let delIds = this.ids;
  1720. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1721. // let realyKey=
  1722. this.addRealFieldName(row);
  1723. if (row[primary] != undefined && row[primary] != null) {
  1724. delIds = [];
  1725. delIds.push(row[primary]);
  1726. }
  1727. let data = {
  1728. basicMap: {
  1729. btnType: btnData.btnType,
  1730. btnKey: btnData.btnKey,
  1731. tableName: this.tableName,
  1732. },
  1733. conditionMap: {
  1734. // id: delIds,
  1735. },
  1736. btnParametersMap: {},
  1737. };
  1738. if (this.currentBtnData.btnParams) {
  1739. let btnParams =
  1740. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  1741. let conditionData =
  1742. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1743. conditionData.forEach((item) => {
  1744. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  1745. ? item.fieldValue
  1746. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1747. });
  1748. btnParams.forEach((item) => {
  1749. data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
  1750. ? item.fieldValue
  1751. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1752. });
  1753. }
  1754. // data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  1755. this.$modal
  1756. .confirm('是否确认删除"' + delIds + '"的数据项?')
  1757. .then(function () {
  1758. // return delTableData(data);
  1759. return btnCommonApi(data);
  1760. })
  1761. .then(() => {
  1762. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  1763. this.$refs.mychild.pageList();
  1764. this.$modal.msgSuccess("删除成功");
  1765. })
  1766. .catch(() => {});
  1767. },
  1768. // 批量删除接口
  1769. handleBatchDelete() {
  1770. let delIds = this.ids;
  1771. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1772. // if (row && row[primary] != undefined && row[primary] != null) {
  1773. // delIds = [];
  1774. // delIds.push(row[primary]);
  1775. // }
  1776. let data = {
  1777. basicMap: {
  1778. tableName: this.tableName,
  1779. },
  1780. conditionMap: {
  1781. // id: delIds,
  1782. },
  1783. };
  1784. // if (this.currentBtnData.btnParams) {
  1785. // let btnParams = JSON.parse(this.currentBtnData.btnParams);
  1786. // btnParams.forEach((item) => {
  1787. // data.btnParametersMap[
  1788. // this.formatField(item.fieldName, camelCase(this.tableName))
  1789. // ] = item.fieldValue
  1790. // ? item.fieldValue
  1791. // : this.currentRow[item.fieldName];
  1792. // });
  1793. // }
  1794. data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  1795. this.$modal
  1796. .confirm('是否确认删除"' + delIds + '"的数据项?')
  1797. .then(function () {
  1798. return delTableData(data);
  1799. // return btnCommonApi(data);
  1800. })
  1801. .then(() => {
  1802. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  1803. this.$refs.mychild.pageList();
  1804. this.$modal.msgSuccess("删除成功");
  1805. })
  1806. .catch(() => {});
  1807. },
  1808. /** 导出按钮操作 */
  1809. handleExport() {
  1810. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1811. let realyKey = camelCase(this.tableName + "_" + primary);
  1812. if (this.ids.length > 0) {
  1813. this.queryParams["execlMap"] = [];
  1814. this.ids.forEach((item) => {
  1815. this.queryParams.execlMap.push(
  1816. this.tableList.find((ttem) => {
  1817. return ttem[realyKey] === item;
  1818. })
  1819. );
  1820. });
  1821. } else {
  1822. this.$message.warning("请至少勾选一条导出数据");
  1823. return;
  1824. }
  1825. this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
  1826. this.download(
  1827. process.env.VUE_APP_BASE_API1 + "common/export",
  1828. {
  1829. ...this.queryParams,
  1830. },
  1831. `文件名称_${new Date().getTime()}.xlsx`
  1832. );
  1833. },
  1834. /** 导入按钮操作 */
  1835. handleImport() {
  1836. this.upload.title = "当前导入";
  1837. this.upload.open = true;
  1838. },
  1839. /** 下载模板操作 */
  1840. importTemplate() {
  1841. this.download(
  1842. process.env.VUE_APP_BASE_API1 +
  1843. `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
  1844. {},
  1845. `下载模版名称${new Date().getTime()}.xlsx`
  1846. );
  1847. },
  1848. // 文件上传中处理
  1849. handleFileUploadProgress(event, file, fileList) {
  1850. this.upload.isUploading = true;
  1851. },
  1852. // 文件上传成功处理
  1853. handleFileSuccess(response, file, fileList) {
  1854. this.upload.open = false;
  1855. this.upload.isUploading = false;
  1856. this.$refs.upload.clearFiles();
  1857. this.$alert(
  1858. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  1859. response.msg +
  1860. "</div>",
  1861. "导入结果",
  1862. { dangerouslyUseHTMLString: true }
  1863. );
  1864. this.$refs.mychild.pageList({
  1865. limit: this.queryParams.pageSize,
  1866. page: this.queryParams.pageNum,
  1867. });
  1868. },
  1869. //重点在这里
  1870. handleChange(file, fileList) {
  1871. file.name = this.tableName + "." + file.name.split(".")[1];
  1872. fileList.forEach((item) => {
  1873. item.name = this.tableName + "." + file.name.split(".")[1];
  1874. });
  1875. let newFile = new File(
  1876. [file],
  1877. this.tableName + "." + file.name.split(".")[1]
  1878. ); //创建出来也是不可编辑的file对象
  1879. },
  1880. // 提交上传文件
  1881. submitFileForm() {
  1882. this.$refs.upload.submit();
  1883. },
  1884. // 弹窗新增的数
  1885. addListHandler(val) {
  1886. this.addLists.push(...val);
  1887. },
  1888. // 绑定弹窗Dialog确定按钮
  1889. btnComfirm() {
  1890. // let data = {
  1891. // addListMap:[],
  1892. // basicMap:{
  1893. // btnType: 10,
  1894. // tableName: this.subTableName,
  1895. // visible: true,
  1896. // },
  1897. // commMap: {},
  1898. // conditionMap: {},
  1899. // }
  1900. // // data.addListMap =
  1901. // btnCommonApi(data).then(res => {
  1902. // console.log('弹窗确定', res);
  1903. // })
  1904. },
  1905. // 去掉表名 开头字母小写
  1906. formatField(field = "", tableName) {
  1907. let temp = field.replace(tableName, "");
  1908. return toUnderline(temp[0].toLowerCase() + temp.slice(1));
  1909. },
  1910. //提交编辑结果按钮回调
  1911. async editConfirmHandler() {
  1912. if (this.$refs.addFromRef) {
  1913. this.$refs.addFromRef
  1914. .getData()
  1915. .then(async (values) => {
  1916. let data = {
  1917. basicMap: {
  1918. tableName: this.tableName,
  1919. // btnKey: btnData.btnKey,
  1920. btnKey: this.currentBtnData.btnKey,
  1921. },
  1922. addListMap: [values],
  1923. conditionMap: {},
  1924. commMap: {},
  1925. btnParametersMap: {},
  1926. };
  1927. if (this.currentBtnData.btnParams) {
  1928. let btnParams =
  1929. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
  1930. [];
  1931. let conditionData =
  1932. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1933. // let
  1934. btnParams.forEach((item) => {
  1935. data.btnParametersMap[item.fieldName.split(".")[1]] =
  1936. item.fieldValue
  1937. ? item.fieldValue
  1938. : this.currentRow[
  1939. camelCase(item.fieldName.replace(".", "_"))
  1940. ];
  1941. });
  1942. conditionData.forEach((item) => {
  1943. data.conditionMap[item.fieldName.split(".")[1]] =
  1944. item.fieldValue
  1945. ? item.fieldValue
  1946. : this.currentRow[
  1947. camelCase(item.fieldName.replace(".", "_"))
  1948. ];
  1949. });
  1950. }
  1951. if (Object.keys(this.defaultValue).length) {
  1952. // data.conditionMap[this.templateInfo.template?.primaryKey] =
  1953. // this.defaultValue[this.templateInfo.template?.primaryKey];
  1954. Object.keys(values).map((k) => {
  1955. data.commMap[k] = values[k];
  1956. });
  1957. data.basicMap.btnType = this.currentBtnData.btnType;
  1958. data.basicMap.visible = true;
  1959. } else {
  1960. data.basicMap.btnType = "INSERT";
  1961. data.basicMap.visible = true;
  1962. }
  1963. try {
  1964. let res = await btnCommonApi(data);
  1965. if (res.code == 200) {
  1966. this.$message.success("操作成功");
  1967. } else {
  1968. this.$message.error("网络异常,请稍后再试");
  1969. }
  1970. } catch (error) {
  1971. console.log(error);
  1972. this.$message.error("网络异常,请稍后再试");
  1973. }
  1974. this.getList();
  1975. this.defaultValue = {};
  1976. this.kOpen = false;
  1977. })
  1978. .catch((res) => {
  1979. console.log(res);
  1980. this.$modal.msgError("表单校验失败,请规范填写数据");
  1981. });
  1982. } else {
  1983. // 没有绑定表单
  1984. let data = {
  1985. basicMap: {
  1986. tableName: this.tableName,
  1987. // btnKey: btnData.btnKey,
  1988. btnKey: this.currentBtnData.btnKey,
  1989. btnType: this.currentBtnData.btnType,
  1990. visible: true,
  1991. },
  1992. addListMap: [],
  1993. conditionMap: {},
  1994. commMap: {},
  1995. btnParametersMap: {},
  1996. };
  1997. if (this.currentBtnData.btnParams) {
  1998. let btnParams =
  1999. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2000. let conditionData =
  2001. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2002. conditionData.forEach((item) => {
  2003. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2004. ? item.fieldValue
  2005. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2006. });
  2007. btnParams.forEach((item) => {
  2008. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2009. item.fieldValue
  2010. ? item.fieldValue
  2011. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2012. });
  2013. }
  2014. // data.basicMap.btnType = this.currentBtnData.btnType;
  2015. // data.basicMap.visible = true;
  2016. try {
  2017. let res = await btnCommonApi(data);
  2018. if (res.code == 200) {
  2019. this.$message.success("操作成功");
  2020. } else {
  2021. this.$message.error("网络异常,请稍后再试");
  2022. }
  2023. } catch (error) {
  2024. console.log(error);
  2025. this.$message.error("网络异常,请稍后再试");
  2026. }
  2027. this.getList();
  2028. this.defaultValue = {};
  2029. this.kOpen = false;
  2030. }
  2031. },
  2032. // 使用提交数据类型的按钮获取数据
  2033. tempSubBtn(getData) {
  2034. getData()
  2035. .then((values) => {
  2036. console.log("验证通过", values);
  2037. })
  2038. .catch(() => {
  2039. console.log("验证未通过,获取失败");
  2040. });
  2041. },
  2042. // 判断是否生效行样式
  2043. cellStyle({ row, column, rowIndex, columnIndex }) {
  2044. let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
  2045. if (!rowStyleList.length) return "";
  2046. let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
  2047. for (let i = 0; i < rowStyleList.length; i++) {
  2048. let item = rowStyleList[i];
  2049. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2050. if (judgeRes) {
  2051. let styleCode = JSON.parse(item.styleCode);
  2052. return `background-color:${styleCode.rowBgColor};`;
  2053. }
  2054. }
  2055. },
  2056. // 获取生效条件组结果
  2057. determineCondition(conditionStr, row) {
  2058. let conditionList = JSON.parse(conditionStr);
  2059. if (!conditionList.length) return false;
  2060. return conditionList.every((item) => this.judgeOneCondition(item, row));
  2061. },
  2062. // 获取单个判断条件结果
  2063. judgeOneCondition(item, row) {
  2064. let fullField = camelCase(item.tableName + "_" + item.fieldName);
  2065. switch (item.condition) {
  2066. case 1:
  2067. return row[fullField] > item.flagValue;
  2068. case 2:
  2069. return row[fullField] < item.flagValue;
  2070. case 3:
  2071. return row[fullField] == item.flagValue;
  2072. case 4:
  2073. return row[fullField] >= item.flagValue;
  2074. case 5:
  2075. return row[fullField] <= item.flagValue;
  2076. default:
  2077. return true; //默认为true
  2078. }
  2079. },
  2080. // 设置表格字段样式
  2081. async setFieldStyleData(tableList) {
  2082. console.log(JSON.parse(JSON.stringify(tableList)));
  2083. let fieldConditionList = this.styleList.filter(
  2084. (item) => item.styleType == 1 || item.styleType == 2
  2085. );
  2086. if (!fieldConditionList.length) return tableList;
  2087. let res = await this.setDictStyleData();
  2088. this.dictStyleObj = res.reduce((pre, item) => {
  2089. return {
  2090. ...pre,
  2091. ...item,
  2092. };
  2093. }, {});
  2094. // console.log("this.dictStyleObj", this.dictStyleObj);
  2095. tableList.forEach((row) => {
  2096. // if (!row.styleFieldObj) row.styleFieldObj = {};
  2097. for (let i = 0; i < fieldConditionList.length; i++) {
  2098. let item = fieldConditionList[i];
  2099. if (item.styleType == 1) {
  2100. //字段样式
  2101. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2102. if (judgeRes) {
  2103. let styleCode = JSON.parse(item.styleCode);
  2104. if (!row.styleFieldObj) row.styleFieldObj = {};
  2105. row.styleFieldObj[item.styleField] = {
  2106. styleType: item.styleType,
  2107. fieldStyleType: styleCode.fieldStyleType,
  2108. fontColor: styleCode.fontColor,
  2109. isTagFullBg: styleCode.isTagFullBg,
  2110. tagType: styleCode.tagType,
  2111. };
  2112. // row.styleField = item.styleField; //样式生效字段
  2113. // row.styleType = item.styleType; //0:行样式 1:字段样式 2:字典样式
  2114. // row.fieldStyleType = styleCode.fieldStyleType; //0:文本 1:标签
  2115. // row.fontColor = styleCode.fontColor;
  2116. // row.isTagFullBg = styleCode.isTagFullBg; //true/false
  2117. // row.tagType = styleCode.tagType; //string
  2118. }
  2119. } else {
  2120. //字典样式
  2121. let dicStyle = this.dictStyleObj[item.styleField]?.find((dict) => {
  2122. return dict.dictValue == row[item.styleField];
  2123. });
  2124. if (dicStyle) {
  2125. if (!row.styleFieldObj) row.styleFieldObj = {};
  2126. row.styleFieldObj[item.styleField] = dicStyle; //设置该字段应该显示的字典样式
  2127. row.styleFieldObj[item.styleField].styleType = 2;
  2128. }
  2129. }
  2130. }
  2131. });
  2132. return tableList;
  2133. },
  2134. //设置表格字典相关数据
  2135. setDictStyleData() {
  2136. let fieldConditionList = this.styleList.filter(
  2137. (item) => item.styleType == 2
  2138. );
  2139. if (!fieldConditionList.length) return;
  2140. let PromiseList = fieldConditionList.map((item) => {
  2141. return new Promise((resolve, reject) => {
  2142. let temp = {};
  2143. try {
  2144. listData({
  2145. isEnablePaging: false,
  2146. dictType: item.styleCondtion,
  2147. }).then((res) => {
  2148. temp[item.styleField] = res.rows;
  2149. resolve(temp);
  2150. });
  2151. } catch (error) {
  2152. reject(error);
  2153. }
  2154. });
  2155. });
  2156. return Promise.all(PromiseList);
  2157. },
  2158. // 内链页面跳转
  2159. routerHandler(btnData, type) {
  2160. let { url, commonFieldData } = JSON.parse(btnData.btnParams);
  2161. let tempArr = [];
  2162. if (commonFieldData) {
  2163. let queryArr = JSON.parse(commonFieldData);
  2164. tempArr = queryArr.map((item) => {
  2165. let key = this.formatField(item.fieldName, camelCase(this.tableName));
  2166. let value = item.fieldValue
  2167. ? item.fieldValue
  2168. : this.currentRow[item.fieldName];
  2169. return key + "=" + value;
  2170. });
  2171. }
  2172. if (tempArr.length) {
  2173. url += "?" + tempArr.join("&");
  2174. }
  2175. // let link = btnData.btnParams;
  2176. if (type == "INNERLINK") {
  2177. this.$router.push(url);
  2178. } else {
  2179. window.open("http://" + url, "_blank");
  2180. }
  2181. },
  2182. async handleDetail(row) {
  2183. this.printDomData = await this.getDetailTableString(row);
  2184. this.detailShow = true;
  2185. this.$nextTick(() => {
  2186. this.$refs.detailTable.innerHTML = this.printDomData;
  2187. });
  2188. },
  2189. // 打印回调
  2190. detailPrintHandler() {
  2191. document.body.innerHTML = document.getElementById("printDom").innerHTML =
  2192. this.printDomData;
  2193. window.print(); //打印
  2194. window.location.reload();
  2195. return false;
  2196. },
  2197. // 获取详情html字符串
  2198. async getDetailTableString(row) {
  2199. let { saleOrderSaleNo } = row;
  2200. let payLoad = [
  2201. {
  2202. basicMap: {
  2203. tableName: "sale_order",
  2204. },
  2205. conditionMap: {
  2206. sale_no: [saleOrderSaleNo],
  2207. },
  2208. },
  2209. {
  2210. basicMap: {
  2211. tableName: "sale_products",
  2212. },
  2213. conditionMap: {
  2214. sale_order_no: [saleOrderSaleNo],
  2215. },
  2216. },
  2217. {
  2218. basicMap: {
  2219. tableName: "sale_craft",
  2220. },
  2221. conditionMap: {
  2222. sale_order_no: [saleOrderSaleNo],
  2223. },
  2224. },
  2225. ];
  2226. let res = await queryDropDownBoxData(payLoad);
  2227. if (res.code == 200) {
  2228. console.log(res);
  2229. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  2230. let {
  2231. //订单表数据
  2232. saleNo, //合同号
  2233. saleCustomNo, //客户编号
  2234. saleDate, //销售单日期
  2235. saleOrderEstimatedTime, //预计下单时间
  2236. saleLeadTime, //交货周期
  2237. saleAmounts, //合计金额 小写
  2238. saleAmountInWords, //合计金额 大写
  2239. salePayType, //支付方式
  2240. salesman, //业务员
  2241. saleLeader, //业务主管
  2242. finance, //财务部
  2243. production, //生产部
  2244. saleApprover, //批准人
  2245. // customAddress, //客户地址
  2246. // customCountryType, //国家类型
  2247. // contactPerson, //联系人
  2248. // 货品明细表数据
  2249. // productNo, //货品号
  2250. // productName, //货品名称
  2251. // productNumber: "", //销售数量
  2252. // productWeight: "", //销售重量kg
  2253. // productUnitPrice: "", //单价
  2254. // productAmounts: "", //金额
  2255. // remark: "", //备注
  2256. // 工艺表
  2257. craftGrid, //网格
  2258. craftOil, //油剂
  2259. craftPackage, //卷装
  2260. craftColorFastness, //色牢度
  2261. craftOther, //其它工艺要求
  2262. craftMark, //包装/贴唛
  2263. shippingMethod, //运输方式
  2264. } = { ...sale_craft[0], ...sale_order[0] };
  2265. let customData = this.customerOptions.find(
  2266. (item) => item.customNo == saleCustomNo
  2267. );
  2268. let customerName = customData ? customData.customName : "";
  2269. let customAddress = customData?.customAddress || "无";
  2270. let customCountryType = customData?.customCountryType || "";
  2271. let contactPerson = customData?.contactPerson || "无";
  2272. let printStr = `
  2273. <table style="width:900px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  2274. <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
  2275. <div style="text-align:center;">销售合同审计单</div>
  2276. <tbody>
  2277. <tr>
  2278. <td width="600px" colspan="4">合同号:${saleNo}</td>
  2279. <td width="300px" colspan="2">日期:${saleDate.replace(
  2280. "T",
  2281. " "
  2282. )}</td>
  2283. </tr>
  2284. <tr align="center">
  2285. <td width="300px" colspan="2">客户名称:</td>
  2286. <td width="300px" colspan="2">${customerName}</td>
  2287. <td width="150px">联系人:</td>
  2288. <td width="150px">${contactPerson}</td>
  2289. </tr>
  2290. <tr align="center">
  2291. <td colspan="2">客户地址:</td>
  2292. <td colspan="2">${customAddress}</td>
  2293. <td>客户国别:</td>
  2294. <td>${customCountryType}</td>
  2295. </tr>
  2296. <tr align="center">
  2297. <td colspan="2">预计下单时间:</td>
  2298. <td colspan="2">${saleOrderEstimatedTime.replace(
  2299. "T",
  2300. " "
  2301. )}</td>
  2302. <td>交货周期:</td>
  2303. <td>${saleLeadTime}</td>
  2304. </tr>
  2305. <tr align="center">
  2306. <td colspan="6">货品明细</td>
  2307. </tr>
  2308. <tr align="center">
  2309. <td width="300px" colspan="2">品名</td>
  2310. <td width="150px">数量/kg</td>
  2311. <td width="150px">单价</td>
  2312. <td width="150px">金额</td>
  2313. <td width="150px">备注</td>
  2314. </tr>`;
  2315. let amountTotal = 0,
  2316. singlTotal = 0,
  2317. moneyTotal = 0;
  2318. for (let i = 0; i < sale_products.length; i++) {
  2319. let item = sale_products[i];
  2320. amountTotal += Number(item.productNumber);
  2321. singlTotal += Number(item.productUnitPrice);
  2322. moneyTotal += Number(item.productAmounts);
  2323. let productData = this.productionOptions.find(
  2324. (pro) => pro.productNo == item.productNo
  2325. );
  2326. let productName = productData ? productData.productName : "";
  2327. printStr += `<tr align="center">
  2328. <td colspan="2">${productName}</td>
  2329. <td>${item.productNumber}</td>
  2330. <td>${item.productUnitPrice}</td>
  2331. <td>${item.productAmounts}</td>
  2332. <td>${item.remark}</td>
  2333. </tr>`;
  2334. }
  2335. // 计算小计
  2336. printStr += `
  2337. <tr align="center">
  2338. <td colspan="2">小计:</td>
  2339. <td>${amountTotal}</td>
  2340. <td>${singlTotal}</td>
  2341. <td>${moneyTotal}</td>
  2342. <td></td>
  2343. </tr>
  2344. <tr>
  2345. <td colspan="6">合计金额(大写):${saleAmountInWords}</td>
  2346. </tr>
  2347. <tr>
  2348. <td colspan="6">付款方式:${salePayType}</td>
  2349. </tr>
  2350. <tr align="center">
  2351. <td colspan="6">工艺要求</td>
  2352. </tr>
  2353. <tr align="center">
  2354. <td width="300px" colspan="2">网格</td>
  2355. <td width="150px">油剂</td>
  2356. <td width="150px">卷装</td>
  2357. <td width="150px">色牢度</td>
  2358. <td width="150px">其他</td>
  2359. </tr>
  2360. <tr align="center">
  2361. <td colspan="2">${craftGrid}</td>
  2362. <td>${craftOil}</td>
  2363. <td>${craftPackage}</td>
  2364. <td>${craftColorFastness}</td>
  2365. <td>${craftOther}</td>
  2366. </tr>
  2367. <tr>
  2368. <td colspan="6">包装/贴唛:${craftMark}</td>
  2369. </tr>
  2370. <tr>
  2371. <td colspan="6">装运方式:${shippingMethod}</td>
  2372. </tr>
  2373. <tr>
  2374. <td colspan="2">业务员:</td>
  2375. <td colspan="2">${salesman}</td>
  2376. <td>业务主管:</td>
  2377. <td>${saleLeader}</td>
  2378. </tr>
  2379. <tr>
  2380. <td colspan="2">财务部:</td>
  2381. <td colspan="2">${finance}</td>
  2382. <td>生产部:</td>
  2383. <td>${production}</td>
  2384. </tr>
  2385. <tr>
  2386. <td colspan="2">批准人:</td>
  2387. <td colspan="2">${saleApprover}</td>
  2388. <td></td>
  2389. <td></td>
  2390. </tr>
  2391. </tbody>
  2392. </table>
  2393. `;
  2394. return printStr;
  2395. // <tr align="center">
  2396. // <td colspan="2"> 2</td>
  2397. // <td> </td>
  2398. // <td> </td>
  2399. // <td> </td>
  2400. // <td> </td>
  2401. // </tr>
  2402. // <tr>
  2403. // <td colspan="2">小计:</td>
  2404. // <td></td>
  2405. // <td></td>
  2406. // <td></td>
  2407. // <td></td>
  2408. // </tr>
  2409. }
  2410. },
  2411. // 操作列回调
  2412. excuteHandler(btnData, row) {
  2413. let { btnType, btnParams, btnFormType } = btnData;
  2414. this.currentBtnData = btnData;
  2415. this.currentRow = JSON.parse(JSON.stringify(row));
  2416. console.log("btnData", btnType, btnData, row);
  2417. // 无表单
  2418. if (btnFormType == "noNeed") {
  2419. this.noNeedHandler(btnData, row);
  2420. return;
  2421. }
  2422. switch (btnType) {
  2423. case "INNERLINK":
  2424. this.routerHandler(btnData, btnType);
  2425. break;
  2426. case "OUTLINK":
  2427. this.routerHandler(btnData, btnType);
  2428. break;
  2429. case "UPDATE":
  2430. this.handleUpdate(row, btnData);
  2431. break;
  2432. case "EXECUTE":
  2433. this.handleUpdate(row, btnData);
  2434. break;
  2435. case "INITIATED":
  2436. this.handleUpdate(row, btnData);
  2437. break;
  2438. case "DELETE":
  2439. this.handleDelete(row, btnData);
  2440. break;
  2441. case "myEdit":
  2442. this.handleEdit("1", row);
  2443. break;
  2444. case "myDetail":
  2445. this.handleDetail(row);
  2446. break;
  2447. default:
  2448. break;
  2449. }
  2450. },
  2451. noNeedHandler(btnData, row) {
  2452. this.$modal
  2453. .confirm("是否确认执行该操作?")
  2454. .then(async () => {
  2455. // 获取默认参数
  2456. let data = {
  2457. basicMap: {
  2458. tableName: this.tableName,
  2459. // btnKey: btnData.btnKey,
  2460. btnKey: this.currentBtnData.btnKey,
  2461. },
  2462. conditionMap: {},
  2463. commMap: {},
  2464. btnParametersMap: {},
  2465. };
  2466. console.log(this.currentBtnData, this.currentRow);
  2467. if (this.currentBtnData.btnParams) {
  2468. let conditionData =
  2469. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2470. // let
  2471. let commonData =
  2472. JSON.parse(this.currentBtnData.btnParams).commonFieldData || [];
  2473. conditionData.forEach((item) => {
  2474. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2475. ? item.fieldValue
  2476. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2477. });
  2478. commonData.forEach((item) => {
  2479. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2480. item.fieldValue
  2481. ? item.fieldValue
  2482. : this.currentRow[
  2483. camelCase(item.fieldName.replace(".", "_"))
  2484. ];
  2485. });
  2486. }
  2487. data.basicMap.btnType = this.currentBtnData.btnType;
  2488. data.basicMap.visible = true;
  2489. try {
  2490. let res = await btnCommonApi(data);
  2491. if (res.code == 200) {
  2492. this.$message.success(res.msg);
  2493. } else {
  2494. this.$message.error("网络异常,请稍后再试");
  2495. }
  2496. } catch (error) {
  2497. console.log(error);
  2498. this.$message.error("网络异常,请稍后再试");
  2499. }
  2500. })
  2501. .then(() => {
  2502. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2503. this.$refs.mychild.pageList();
  2504. // this.$modal.msgSuccess("操作成功");
  2505. })
  2506. .catch(() => {});
  2507. },
  2508. // k-form-build表单变化回调
  2509. formChangeHandler(value, label) {
  2510. // console.log(value, label);
  2511. },
  2512. },
  2513. };
  2514. </script>
  2515. <style scoped lang="scss">
  2516. ::v-deep .el-dialog:not(.is-fullscreen) {
  2517. min-width: 610px !important;
  2518. }
  2519. </style>