financeApprove.vue 76 KB

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