approve.vue 74 KB

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