64be11939bb19aeb4ae7246e0fe0e7a98be6f417.svn-base 109 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <div class="recipeTemplate">
  6. <p>配方模板表</p>
  7. </div>
  8. <div class="operation">
  9. <el-button class="success" @click="handleCreate">新增</el-button>
  10. <el-button class="danger" @click="handleDelete">删除</el-button>
  11. <el-button class="warning" @click="handleCopy">复制</el-button>
  12. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  13. <el-button class="success" @click="handleHistory">生成历史</el-button>
  14. <el-upload style="float: right;margin-right: 75px;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  15. <el-button class="import" style="float: right;">导入</el-button>
  16. </el-upload>
  17. <el-dropdown style="float: right;margin-right: 10px;">
  18. <el-button class="export">导出</el-button>
  19. <el-dropdown-menu slot="dropdown">
  20. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  21. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. <el-button class="import" style="float: right;margin-right: 10px;" @click="handleHistoryRecord">历史记录</el-button>
  25. </div>
  26. <div class="search">
  27. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  28. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  29. </el-select>
  30. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  31. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  32. </el-select>
  33. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  34. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  35. </el-select>
  36. <div ref="selectInput" class="filter-item selectInput">
  37. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  38. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  39. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  40. <ul v-if="arrowUp" class="selectUl">
  41. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  42. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  43. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  44. <li>
  45. <div style="float: right;">
  46. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  47. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  48. </div>
  49. </li>
  50. </ul>
  51. </div>
  52. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  53. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  54. </div>
  55. <div class="table">
  56. <el-table
  57. :key="table.tableKey"
  58. v-loading="table.listLoading"
  59. element-loading-text="给我一点时间"
  60. :data="table.list"
  61. border
  62. fit
  63. highlight-current-row
  64. style="width: 98%;"
  65. :row-style="rowStyle"
  66. :cell-style="cellStyle"
  67. class="elTable table-fixed"
  68. @row-click="tableRowClick"
  69. @selection-change="handleSelectionChange"
  70. >
  71. <el-table-column type="selection" align="center" width="50" />
  72. <el-table-column label="序号" align="center" type="index" width="50px">
  73. <template slot-scope="scope">
  74. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="配方名称" min-width="110px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  80. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="配方颜色" min-width="85px" align="center">
  84. <template slot-scope="scope">
  85. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="牲畜类别" min-width="130px" align="center">
  89. <template slot-scope="scope">
  90. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  91. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  92. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  93. </el-select>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="配方类型" min-width="130px" align="center">
  97. <template slot-scope="scope">
  98. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  99. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  100. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  101. </el-select>
  102. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  103. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  104. </el-select>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="来源" min-width="90px" align="center">
  108. <template slot-scope="scope">
  109. <span>{{ scope.row.source }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="备注" min-width="90px" align="center">
  113. <template slot-scope="scope">
  114. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  115. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="版本号" min-width="90px" align="center">
  119. <template slot-scope="scope">
  120. <span>{{ scope.row.source }}</span>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="是否启用" min-width="90px" align="center">
  124. <template slot-scope="scope">
  125. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  129. <template slot-scope="{row}">
  130. <!-- 新增 -->
  131. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  132. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  133. <!-- 编辑 -->
  134. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  135. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  136. <!-- 编辑保存 -->
  137. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  138. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  139. <el-button v-if="row.NoEdit" class="miniSuccess" @click="handleFormulationEvaluation(row)">配方评估</el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. </div>
  144. </div>
  145. <!-- 配方详情表 -->
  146. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  147. <div class="recipeTemplate">
  148. <p>配方详情表</p>
  149. </div>
  150. <div class="operation">
  151. <el-button class="success" @click="handleCreate2">新增</el-button>
  152. <el-button class="danger" @click="handleDelete2">删除</el-button>
  153. <el-button class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  154. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  155. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  156. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  157. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  158. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  159. <li>
  160. <a style="width: 130px;">饲料名称</a>
  161. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  162. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  163. </el-select>
  164. </li>
  165. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  166. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  167. <li>
  168. <a style="width: 130px;">搅拌延时</a>
  169. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  170. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  171. </el-select>
  172. </li>
  173. <li>
  174. <a style="width: 130px;">是否锁定牛头数比例</a>
  175. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  176. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  177. </el-select>
  178. </li>
  179. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  180. <li>
  181. <div style="float: right;">
  182. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  183. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  184. </div>
  185. </li>
  186. </ul>
  187. </div>
  188. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  189. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  190. </div>
  191. <div class="table2" style="min-height: 400px;">
  192. <el-table
  193. id="table2"
  194. ref="table2"
  195. :key="table2.tableKey"
  196. v-loading="table2.listLoading"
  197. element-loading-text="给我一点时间"
  198. :data="table2.list"
  199. border
  200. fit
  201. highlight-current-row
  202. style="width: 98%;"
  203. :row-style="rowStyle"
  204. :cell-style="cellStyle"
  205. class="elTable table-fixed"
  206. row-key="id"
  207. :summary-method="getSummaries"
  208. show-summary
  209. @selection-change="handleSelectionChange2"
  210. >
  211. <el-table-column type="selection" width="60" />
  212. <el-table-column label="序号" align="center" type="index" width="50px" />
  213. <el-table-column label="饲料组" min-width="110px" align="center">
  214. <template slot-scope="scope">
  215. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  216. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  217. </template>
  218. </el-table-column>
  219. <el-table-column label="饲料名称" min-width="130px" align="center">
  220. <template slot-scope="scope">
  221. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  222. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  223. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  224. </el-select>
  225. </template>
  226. </el-table-column>
  227. <el-table-column label="重量(KG)" prop="fweight" min-width="100px" align="center">
  228. <template slot-scope="scope">
  229. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  230. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  231. </template>
  232. </el-table-column>
  233. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  234. <template slot-scope="scope">
  235. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  236. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  237. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  238. </el-select>
  239. </template>
  240. </el-table-column>
  241. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  242. <template slot-scope="scope">
  243. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  244. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  245. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  246. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  247. </el-select>
  248. </template>
  249. </el-table-column>
  250. <el-table-column label="顺序" min-width="100px" align="center">
  251. <template slot-scope="scope">
  252. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  253. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  254. </template>
  255. </el-table-column>
  256. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  257. <template slot-scope="{row}">
  258. <!-- 新增 -->
  259. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  260. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  261. <!-- 编辑 -->
  262. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  263. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  264. <!-- 编辑保存 -->
  265. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  266. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  267. <!-- 拆分预混料 -->
  268. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  269. </template>
  270. </el-table-column>
  271. </el-table>
  272. </div>
  273. </div>
  274. <!-- 配方记录 -->
  275. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  276. <div style="height: 400px;overflow: auto;margin-bottom: 30px;">
  277. <div ref="templateDialog" class="templateDialog">
  278. <div class="recipeTemplate">
  279. <p>配方模板表</p>
  280. </div>
  281. <div class="operation">
  282. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  283. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  284. </div>
  285. <div class="search">
  286. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  287. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  288. </el-select>
  289. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  290. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  291. </el-select>
  292. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  293. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  294. </el-select>
  295. <div ref="selectInput" class="filter-item selectInput">
  296. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  297. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  298. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  299. <ul v-if="arrowUp" class="selectUl">
  300. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  301. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  302. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  303. <li>
  304. <div style="float: right;">
  305. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  306. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  307. </div>
  308. </li>
  309. </ul>
  310. </div>
  311. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  312. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  313. </div>
  314. <div class="table">
  315. <el-table
  316. :key="template.table.tableKey"
  317. v-loading="template.table.listLoading"
  318. element-loading-text="给我一点时间"
  319. :data="template.table.list"
  320. border
  321. fit
  322. highlight-current-row
  323. style="width: 98%;"
  324. :row-style="rowStyle"
  325. :cell-style="cellStyle"
  326. class="elTable table-fixed"
  327. @row-click="tableRowClickDialog"
  328. >
  329. <el-table-column label="序号" align="center" type="index" width="50px">
  330. <template slot-scope="scope">
  331. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  332. </template>
  333. </el-table-column>
  334. <el-table-column label="配方名称" min-width="130px" align="center">
  335. <template slot-scope="scope">
  336. <span>{{ scope.row.tname }}</span>
  337. </template>
  338. </el-table-column>
  339. <el-table-column label="配方颜色" min-width="130px" align="center">
  340. <template slot-scope="scope">
  341. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  342. </template>
  343. </el-table-column>
  344. <el-table-column label="牲畜类别" min-width="150px" align="center">
  345. <template slot-scope="scope">
  346. <span>{{ scope.row.ccname }}</span>
  347. </template>
  348. </el-table-column>
  349. <el-table-column label="配方类型" min-width="150px" align="center">
  350. <template slot-scope="scope">
  351. <span>{{ scope.row.fttype }}</span>
  352. </template>
  353. </el-table-column>
  354. <el-table-column label="来源" min-width="110px" align="center">
  355. <template slot-scope="scope">
  356. <span>{{ scope.row.source }}</span>
  357. </template>
  358. </el-table-column>
  359. <el-table-column label="备注" min-width="110px" align="center">
  360. <template slot-scope="scope">
  361. <span>{{ scope.row.remark }}</span>
  362. </template>
  363. </el-table-column>
  364. <el-table-column label="是否启用" min-width="110px" align="center">
  365. <template slot-scope="scope">
  366. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  367. </template>
  368. </el-table-column>
  369. </el-table>
  370. </div>
  371. </div>
  372. <div v-if="isDetailDialog" class="detailDialog" style="margin-top: 30px;">
  373. <div class="recipeTemplate">
  374. <p>配方详情表</p>
  375. </div>
  376. <div class="operation">
  377. <div ref="selectInput2" class="filter-item selectInput">
  378. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  379. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  380. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  381. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  382. <li>
  383. <a style="width: 130px;">饲料名称</a>
  384. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  385. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  386. </el-select>
  387. </li>
  388. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  389. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  390. <li>
  391. <a style="width: 130px;">搅拌延时</a>
  392. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  393. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  394. </el-select>
  395. </li>
  396. <li>
  397. <a style="width: 130px;">是否锁定牛头数比例</a>
  398. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  399. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  400. </el-select>
  401. </li>
  402. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  403. <li>
  404. <div style="float: right;">
  405. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  406. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  407. </div>
  408. </li>
  409. </ul>
  410. </div>
  411. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  412. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  413. </div>
  414. <div class="table2">
  415. <el-table
  416. :key="template.table2.tableKey"
  417. v-loading="template.table2.listLoading"
  418. element-loading-text="给我一点时间"
  419. :data="template.table2.list"
  420. border
  421. fit
  422. highlight-current-row
  423. style="width: 98%;"
  424. :row-style="rowStyle"
  425. :cell-style="cellStyle"
  426. class="elTable table-fixed"
  427. row-key="id"
  428. >
  429. <el-table-column label="饲料组" min-width="130px" align="center">
  430. <template slot-scope="scope">
  431. <span>{{ scope.row.feedgroup }}</span>
  432. </template>
  433. </el-table-column>
  434. <el-table-column label="饲料名称" min-width="130px" align="center">
  435. <template slot-scope="scope">
  436. <span>{{ scope.row.fname }}</span>
  437. </template>
  438. </el-table-column>
  439. <el-table-column label="重量(KG)" min-width="130px" align="center">
  440. <template slot-scope="scope">
  441. <span>{{ scope.row.fweight }}</span>
  442. </template>
  443. </el-table-column>
  444. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  445. <template slot-scope="scope">
  446. <span>{{ scope.row.autosecondname }}</span>
  447. </template>
  448. </el-table-column>
  449. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  450. <template slot-scope="scope">
  451. <span v-if="scope.row.islockcount == '0'">否</span>
  452. <span v-if="scope.row.islockcount == '1'">是</span>
  453. </template>
  454. </el-table-column>
  455. <el-table-column label="顺序" min-width="130px" align="center">
  456. <template slot-scope="scope">
  457. <span>{{ scope.row.sort }}</span>
  458. </template>
  459. </el-table-column>
  460. </el-table>
  461. </div>
  462. </div>
  463. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  464. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  465. </div>
  466. </div>
  467. </el-dialog>
  468. <!-- 合成预混料 -->
  469. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  470. <div class="detailDialog">
  471. <h2>饲料</h2>
  472. <div class="table1">
  473. <el-table
  474. :key="detail.tableKey"
  475. v-loading="detail.listLoading"
  476. element-loading-text="给我一点时间"
  477. :data="detail.list"
  478. fit
  479. highlight-current-row
  480. style="width: 100%;"
  481. :row-style="rowStyle"
  482. :cell-style="cellStyle"
  483. class="elTable table-fixed"
  484. show-summary
  485. >
  486. <el-table-column label="序号" align="center" type="index" width="50px" />
  487. <el-table-column label="饲料名称" min-width="130px" align="center">
  488. <template slot-scope="scope">
  489. <span>{{ scope.row.fname }}</span>
  490. </template>
  491. </el-table-column>
  492. <el-table-column prop="fweight" label="重量(KG)" />
  493. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  494. <template slot-scope="scope">
  495. <span>{{ scope.row.autosecond }}</span>
  496. </template>
  497. </el-table-column>
  498. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  499. <template slot-scope="scope">
  500. <span v-if="scope.row.islockcount == '0'">否</span>
  501. <span v-if="scope.row.islockcount == '1'">是</span>
  502. </template>
  503. </el-table-column>
  504. <el-table-column label="顺序" min-width="110px" align="center">
  505. <template slot-scope="scope">
  506. <span>{{ scope.row.sort }}</span>
  507. </template>
  508. </el-table-column>
  509. </el-table>
  510. </div>
  511. <h2>合成预混料</h2>
  512. <div class="table2" style="margin-bottom: 50px;">
  513. <el-table
  514. :key="detail.tableKey2"
  515. v-loading="detail.listLoading2"
  516. element-loading-text="给我一点时间"
  517. :data="detail.list2"
  518. border
  519. fit
  520. highlight-current-row
  521. style="width: 100%;"
  522. :row-style="rowStyle"
  523. :cell-style="cellStyle"
  524. class="elTable table-fixed"
  525. >
  526. <el-table-column label="配方名称" min-width="130px" align="center">
  527. <template slot-scope="scope">
  528. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  529. </template>
  530. </el-table-column>
  531. <el-table-column label="配方颜色11" min-width="130px" align="center">
  532. <template slot-scope="scope">
  533. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  534. </template>
  535. </el-table-column>
  536. <el-table-column label="牲畜类别" min-width="130px" align="center">
  537. <template slot-scope="scope">
  538. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  539. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  540. </el-select>
  541. </template>
  542. </el-table-column>
  543. <el-table-column label="配方类型" min-width="110px" align="center">
  544. <template slot-scope="scope">
  545. <span>{{ scope.row.fttype }}</span>
  546. </template>
  547. </el-table-column>
  548. <el-table-column label="来源" min-width="110px" align="center">
  549. <template slot-scope="scope">
  550. <span>{{ scope.row.source }}</span>
  551. </template>
  552. </el-table-column>
  553. <el-table-column label="备注" min-width="130px" align="center">
  554. <template slot-scope="scope">
  555. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  556. </template>
  557. </el-table-column>
  558. <el-table-column label="是否启用" min-width="130px" align="center">
  559. <template slot-scope="scope">
  560. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  561. </template>
  562. </el-table-column>
  563. </el-table>
  564. </div>
  565. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  566. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  567. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  568. </div>
  569. </div>
  570. </el-dialog>
  571. <!-- 历史记录 -->
  572. <el-dialog :title="textMap[historyRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  573. <div class="historyRecord">
  574. <keep-alive>
  575. <component :is="historyRecord.myComponent" ref="historyRecord" />
  576. </keep-alive>
  577. </div>
  578. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  579. <el-button class="cancelClose" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  580. </div>
  581. </el-dialog>
  582. </div>
  583. </template>
  584. <script>
  585. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig, formatNum } from '@/api/common'
  586. import Sortable from 'sortablejs'
  587. import { MessageBox } from 'element-ui'
  588. import Cookies from 'js-cookie'
  589. import { json2excel } from '@/utils/index.js'
  590. import { getToken } from '@/utils/auth'
  591. export default {
  592. name: 'RecipeTemplate',
  593. data() {
  594. return {
  595. requestParams: [
  596. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  597. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  598. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  599. ],
  600. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  601. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  602. livestockTypeList: [], // 牲畜类别
  603. formulaTypeList: [], // 配方类型
  604. feedNameList: [], // 饲料名称
  605. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  606. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  607. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  608. arrowDown: true,
  609. arrowUp: false,
  610. table: {
  611. getdataListParm: {
  612. name: 'getFTList',
  613. page: 1,
  614. offset: 1,
  615. pagecount: 30,
  616. returntype: 'Map',
  617. parammaps: {
  618. pastureid: Cookies.get('pastureid'),
  619. tname: '',
  620. ccid: '',
  621. ccname: '',
  622. fttypeid: '',
  623. fttype: '',
  624. remark: '',
  625. enable: ''
  626. }
  627. },
  628. tableKey: 0,
  629. list: [],
  630. total: 0,
  631. listLoading: true,
  632. temp: {}
  633. },
  634. lockCount: {
  635. getdataListParm: {
  636. name: 'getSysoptEnable',
  637. page: 1,
  638. offset: 1,
  639. pagecount: 30,
  640. returntype: 'Map',
  641. parammaps: {
  642. pastureid: Cookies.get('pastureid'),
  643. inforname: 'isLockCount'
  644. }
  645. },
  646. isLockCount: false // 是否显示是否锁定牛头数比例
  647. },
  648. isDetail: false,
  649. arrowDown2: true,
  650. arrowUp2: false,
  651. table2: {
  652. getdataListParm: {
  653. name: 'getFTdetailList',
  654. page: 1,
  655. offset: 1,
  656. pagecount: 10,
  657. returntype: 'Map',
  658. parammaps: {
  659. pastureid: Cookies.get('pastureid'),
  660. fname: '',
  661. feedgroup: '',
  662. fweight: '',
  663. autosecondname: '',
  664. islockcount: '',
  665. sort: ''
  666. }
  667. },
  668. tableKey: 0,
  669. list: [],
  670. total: 0,
  671. listLoading: true,
  672. temp: {}
  673. },
  674. isDetailDialog: false,
  675. template: {
  676. dialogFormVisible: false,
  677. dialogStatus: '',
  678. table: {
  679. getdataListParm: {
  680. name: 'getFTListDate',
  681. page: 1,
  682. offset: 1,
  683. pagecount: 10,
  684. returntype: 'Map',
  685. parammaps: {
  686. pastureid: Cookies.get('pastureid'),
  687. tname: '',
  688. ccid: '',
  689. ccname: '',
  690. fttype: '',
  691. remark: '',
  692. enable: '',
  693. date: '',
  694. source: ''
  695. }
  696. },
  697. tableKey: 0,
  698. total: 0,
  699. listLoading: true,
  700. list: []
  701. },
  702. table2: {
  703. getdataListParm: {
  704. name: 'getFTdetailListDate',
  705. page: 1,
  706. offset: 1,
  707. pagecount: 10,
  708. returntype: 'Map',
  709. parammaps: {
  710. pastureid: Cookies.get('pastureid'),
  711. fname: '',
  712. fweight: '',
  713. islockcount: '',
  714. sort: '',
  715. feedgroup: '',
  716. autosecondname: ''
  717. }
  718. },
  719. tableKey: 0,
  720. total: 0,
  721. listLoading: true,
  722. list: []
  723. },
  724. // 历史日期
  725. getdataDateParm: {
  726. name: 'getFTMaxDate',
  727. page: 1,
  728. offset: 1,
  729. pagecount: 10,
  730. returntype: 'Map',
  731. parammaps: {
  732. pastureid: Cookies.get('pastureid')
  733. }
  734. }
  735. },
  736. detail: {
  737. dialogFormVisible: false,
  738. dialogStatus: '',
  739. tableKey: 0,
  740. total: 0,
  741. listLoading: true,
  742. list: [],
  743. tableKey2: 0,
  744. total2: 0,
  745. listLoading2: false,
  746. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  747. getdataListParm: {
  748. name: 'getFTDetailCompare',
  749. page: 1,
  750. offset: 1,
  751. pagecount: 10,
  752. returntype: 'Map',
  753. parammaps: {}
  754. },
  755. list3: [],
  756. disabled: false,
  757. getdataListParm2: {
  758. name: 'getFTCompare',
  759. page: 1,
  760. offset: 1,
  761. pagecount: 10,
  762. returntype: 'Map',
  763. parammaps: {}
  764. }
  765. },
  766. selectList: [],
  767. selectList2: [],
  768. textMap: {
  769. RecipeRecord: '配方记录',
  770. SyntheticPremix: '合成预混料',
  771. historyRecord: '历史记录'
  772. },
  773. requestParam: {},
  774. download: {
  775. getdataListParm: {
  776. name: 'getFTList',
  777. page: 1,
  778. offset: 1,
  779. pagecount: 0,
  780. returntype: 'Map',
  781. parammaps: {
  782. pastureid: Cookies.get('pastureid'),
  783. tname: '',
  784. ccid: '',
  785. ccname: '',
  786. fttypeid: '',
  787. fttype: '',
  788. remark: '',
  789. enable: ''
  790. }
  791. },
  792. list: []
  793. },
  794. historyRecord: {
  795. dialogStatus: '',
  796. dialogFormVisible: false
  797. },
  798. isokDisable: false,
  799. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  800. cellStyle: { padding: 0 + 'px' },
  801. dropState: false
  802. }
  803. },
  804. computed: {
  805. // 设置请求头
  806. headers() {
  807. return {
  808. token: getToken()
  809. }
  810. },
  811. uploadData() {
  812. return {
  813. name: '颛孙洋洋-配方模板',
  814. importParams: '配方名称, 牲畜类别, 配方类型, 备注, 是否启用, 饲料组, 饲料名称, 重量(kg), 搅拌延时(min), 是否锁定牛头数比例',
  815. sheetname: 'SheetJS'
  816. }
  817. },
  818. // 设置上传地址
  819. uploadExcelUrl() {
  820. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  821. }
  822. },
  823. mounted() {
  824. document.addEventListener('click', (e) => {
  825. if (this.$refs.selectInput !== undefined) {
  826. if (!this.$refs.selectInput.contains(e.target)) {
  827. this.arrowDown = true
  828. this.arrowUp = false
  829. } else {
  830. this.arrowDown = false
  831. this.arrowUp = true
  832. }
  833. }
  834. if (this.$refs.selectInput2 !== undefined) {
  835. if (!this.$refs.selectInput2.contains(e.target)) {
  836. this.arrowDown2 = true
  837. this.arrowUp2 = false
  838. } else {
  839. this.arrowDown2 = false
  840. this.arrowUp2 = true
  841. }
  842. }
  843. })
  844. },
  845. created() {
  846. this.getList()
  847. this.getDownList()
  848. this.getIsLockCount()
  849. },
  850. methods: {
  851. getSummaries(param) {
  852. console.log(param, '====')
  853. const { columns, data } = param
  854. const sums = []
  855. columns.forEach((column, index) => {
  856. if (index === 0) {
  857. sums[index] = '总价'
  858. return
  859. }
  860. const values = data.map(item => Number(item[column.property]))
  861. if (!values.every(value => isNaN(value))) {
  862. sums[index] = values.reduce((prev, curr) => {
  863. const value = Number(curr)
  864. if (!isNaN(value)) {
  865. return prev + curr
  866. } else {
  867. return prev
  868. }
  869. }, 0)
  870. sums[index] += '(干物质量:是待发值)'
  871. // 后台待发
  872. // sums[index] += '(干物质量:' + param.data[0].feedgroup + ')'
  873. } else {
  874. sums[index] = ''
  875. }
  876. })
  877. return sums
  878. },
  879. handleHistory() {
  880. MessageBox.confirm('是否确认生成历史?', {
  881. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  882. }).then(() => {
  883. this.requestParam.name = 'creatFTdate'
  884. this.requestParam.parammaps = {}
  885. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  886. PostDataByName(this.requestParam).then(response => {
  887. console.log('生成历史保存发送参数', this.requestParam)
  888. if (response.msg !== 'fail') {
  889. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  890. } else {
  891. failproccess(response, this.$notify)
  892. }
  893. })
  894. })
  895. },
  896. getDownList() {
  897. GetDataByNames(this.requestParams).then(response => {
  898. this.livestockTypeList = response.data.getDictByName.list
  899. this.formulaTypeList = response.data.getDictByName2.list
  900. this.feedNameList = response.data.getFeedAndPre.list
  901. })
  902. },
  903. // -------------------模板-----------------------------
  904. getList() {
  905. this.table.listLoading = true
  906. GetDataByName(this.table.getdataListParm).then(response => {
  907. console.log('table数据', response.data.list)
  908. if (response.data.list !== null) {
  909. for (let i = 0; i < response.data.list.length; i++) {
  910. this.$set(response.data.list[i], 'Edit', false) // 编辑
  911. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  912. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  913. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  914. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  915. }
  916. this.table.list = response.data.list
  917. this.table.pageNum = response.data.pageNum
  918. this.table.pageSize = response.data.pageSize
  919. this.table.total = response.data.total
  920. } else {
  921. this.table.list = []
  922. }
  923. setTimeout(() => {
  924. this.table.listLoading = false
  925. }, 100)
  926. })
  927. },
  928. handleSearch() {
  929. console.log('点击了查询')
  930. this.table.getdataListParm.offset = 1
  931. this.getList()
  932. this.arrowDown = true
  933. this.arrowUp = false
  934. },
  935. handleRefresh() {
  936. console.log('点击了重置')
  937. this.table.getdataListParm.offset = 1
  938. this.table.getdataListParm.parammaps.ccid = ''
  939. this.table.getdataListParm.parammaps.ccname = ''
  940. this.table.getdataListParm.parammaps.fttype = ''
  941. this.table.getdataListParm.parammaps.tname = ''
  942. this.table.getdataListParm.parammaps.remark = ''
  943. this.table.getdataListParm.parammaps.enable = ''
  944. this.table.getdataListParm.parammaps.source = ''
  945. this.getList()
  946. },
  947. // 模板新增
  948. handleCreate() {
  949. console.log('点击了新增')
  950. // 编辑true/不可编辑false
  951. // 新增操true,编辑false,编辑保存false
  952. for (let i = 0; i < this.table.list.length; i++) {
  953. if (this.table.list[i].Edit === true) {
  954. console.log(123)
  955. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  956. return false
  957. }
  958. }
  959. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  960. console.log(this.table.list)
  961. },
  962. // 畜生类别
  963. changeLivestockType(item) {
  964. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  965. },
  966. // 配方类型
  967. changeFormulaType(item) {
  968. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  969. },
  970. createData(row) {
  971. console.log('点击了新增保存', row)
  972. this.table.temp.tname = row.tname
  973. this.table.temp.tcolor = row.tcolor
  974. this.table.temp.ccid = row.ccid
  975. this.table.temp.ccname = this.table.temp.ccname
  976. this.table.temp.fttype = this.table.temp.fttype
  977. this.table.temp.fttypeid = row.fttypeid
  978. this.table.temp.source = row.source
  979. this.table.temp.remark = row.remark
  980. this.table.temp.enable = row.enable
  981. this.table.temp.pastureid = Cookies.get('pastureid')
  982. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  983. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  984. return false
  985. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  986. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  987. return false
  988. } else if (this.table.temp.tname == '') {
  989. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  990. return false
  991. } else if (this.table.temp.ccid == '') {
  992. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  993. return false
  994. } else if (this.table.temp.fttypeid == '') {
  995. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  996. return false
  997. }
  998. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  999. if (pattern.test(this.table.temp.tname)) {
  1000. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1001. return false
  1002. }
  1003. console.log(this.table.temp)
  1004. this.isokDisable = true
  1005. setTimeout(() => {
  1006. this.isokDisable = false
  1007. }, 1000)
  1008. this.requestParam.name = 'insertFT'
  1009. this.requestParam.parammaps = this.table.temp
  1010. PostDataByName(this.requestParam).then(response => {
  1011. console.log('新增保存发送参数', this.requestParam)
  1012. if (response.msg !== 'fail') {
  1013. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1014. this.getList()
  1015. } else {
  1016. failproccess(response, this.$notify)
  1017. }
  1018. })
  1019. },
  1020. createCancel(row) {
  1021. console.log('点击了新增取消')
  1022. for (let i = 0; i < this.table.list.length; i++) {
  1023. if (row.myId === this.table.list[i].myId) {
  1024. var listIndex = this.table.list.indexOf(this.table.list[i])
  1025. }
  1026. if (listIndex > -1) {
  1027. this.table.list.splice(listIndex, 1)
  1028. return
  1029. }
  1030. }
  1031. },
  1032. // 模板编辑
  1033. handleUpdate(row) {
  1034. for (let i = 0; i < this.table.list.length; i++) {
  1035. if (this.table.list[i].Edit == true) {
  1036. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1037. return false
  1038. }
  1039. }
  1040. // 编辑true,不可编辑false
  1041. row.Edit = true
  1042. row.NoEdit = false
  1043. // 新增false,编辑false,编辑保存true
  1044. row.isCreate = false
  1045. row.isUpdate = false
  1046. row.isUpdateSave = true
  1047. row.ccid = String(row.ccid)
  1048. row.fttypeid = String(row.fttypeid)
  1049. this.table.temp.ccname = row.ccname
  1050. this.table.temp.fttype = row.fttype
  1051. },
  1052. updateData(row) {
  1053. console.log('点击了编辑保存', row)
  1054. this.table.temp.tname = row.tname
  1055. this.table.temp.tcolor = row.tcolor
  1056. this.table.temp.ccid = row.ccid
  1057. this.table.temp.fttypeid = row.fttypeid
  1058. this.table.temp.source = row.source
  1059. this.table.temp.remark = row.remark
  1060. this.table.temp.enable = row.enable
  1061. this.table.temp.ccname = this.table.temp.ccname
  1062. this.table.temp.fttype = this.table.temp.fttype
  1063. this.table.temp.pastureid = row.pastureid
  1064. this.table.temp.id = row.id
  1065. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1066. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1067. return false
  1068. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1069. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1070. return false
  1071. } else if (this.table.temp.tname == '') {
  1072. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1073. return false
  1074. } else if (this.table.temp.ccid == '') {
  1075. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1076. return false
  1077. } else if (this.table.temp.fttypeid == '') {
  1078. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1079. return false
  1080. }
  1081. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1082. if (pattern.test(this.table.temp.tname)) {
  1083. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1084. return false
  1085. }
  1086. console.log(this.table.temp)
  1087. this.isokDisable = true
  1088. setTimeout(() => {
  1089. this.isokDisable = false
  1090. }, 1000)
  1091. this.requestParam.name = 'updateFT'
  1092. this.requestParam.parammaps = this.table.temp
  1093. PostDataByName(this.requestParam).then(response => {
  1094. console.log('新增保存发送参数', this.requestParam)
  1095. if (response.msg !== 'fail') {
  1096. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1097. this.getList()
  1098. } else {
  1099. failproccess(response, this.$notify)
  1100. }
  1101. })
  1102. },
  1103. updateCancel(row) {
  1104. console.log('点击了编辑取消')
  1105. // 编辑false,不可编辑true
  1106. row.Edit = false
  1107. row.NoEdit = true
  1108. // 新增false,编辑true,编辑保存false
  1109. row.isCreate = false
  1110. row.isUpdate = true
  1111. row.isUpdateSave = false
  1112. this.getList()
  1113. },
  1114. // 删除
  1115. handleRowDelete(row) {
  1116. console.log('点击了行内删除')
  1117. MessageBox.confirm('是否确认删除此信息?', {
  1118. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1119. }).then(() => {
  1120. this.requestParam.common = { 'returnmap': '0' }
  1121. this.requestParam.data = []
  1122. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1123. pastureid: row.pastureid,
  1124. id: row.id
  1125. }}
  1126. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1127. pastureid: row.pastureid,
  1128. id: row.id
  1129. }}
  1130. ExecDataByConfig(this.requestParam).then(response => {
  1131. console.log('新增保存发送参数', this.requestParam)
  1132. if (response.msg === 'fail') {
  1133. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1134. } else {
  1135. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1136. this.getList()
  1137. this.isDetail = false
  1138. }
  1139. })
  1140. }).catch(() => {
  1141. this.$message({ type: 'info', message: '已取消删除' })
  1142. })
  1143. },
  1144. handleSelectionChange(val) {
  1145. console.log('勾选数据', val)
  1146. this.selectList = val
  1147. },
  1148. handleDelete() {
  1149. console.log('点击了删除')
  1150. if (this.selectList.length == 0) {
  1151. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1152. } else {
  1153. MessageBox.confirm('是否确认删除此信息?', {
  1154. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1155. }).then(() => {
  1156. console.log(this.selectList)
  1157. this.requestParam.common = { 'returnmap': '0' }
  1158. this.requestParam.data = []
  1159. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1160. this.requestParam.data[0].children = []
  1161. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1162. id: '@insertSpotList.id',
  1163. pastureid: '@insertSpotList.pastureid'
  1164. }}
  1165. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1166. id: '@insertSpotList.id',
  1167. pastureid: '@insertSpotList.pastureid'
  1168. }}
  1169. ExecDataByConfig(this.requestParam).then(response => {
  1170. console.log('删除保存发送参数', this.requestParam)
  1171. if (response.msg === 'fail') {
  1172. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1173. } else {
  1174. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1175. this.getList()
  1176. }
  1177. })
  1178. })
  1179. }
  1180. },
  1181. // 复制
  1182. handleCopy() {
  1183. if (this.selectList.length == 0) {
  1184. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1185. } else {
  1186. MessageBox.confirm('是否确认复制此信息?', {
  1187. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1188. }).then(() => {
  1189. console.log(this.selectList)
  1190. this.requestParam.common = { 'returnmap': '0' }
  1191. this.requestParam.data = []
  1192. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1193. this.requestParam.data[0].children = []
  1194. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1195. ftid: '@insertSpotList.id',
  1196. pastureid: '@insertSpotList.pastureid'
  1197. }}
  1198. ExecDataByConfig(this.requestParam).then(response => {
  1199. console.log('复制保存发送参数', this.requestParam)
  1200. if (response.msg === 'fail') {
  1201. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1202. } else {
  1203. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1204. this.getList()
  1205. }
  1206. })
  1207. })
  1208. }
  1209. },
  1210. // 配方记录
  1211. handleRecipeRecord() {
  1212. console.log('点击了配方记录')
  1213. this.template.dialogStatus = 'RecipeRecord'
  1214. this.template.dialogFormVisible = true
  1215. this.template.table.getdataListParm.parammaps.ccname = ''
  1216. this.template.table.getdataListParm.parammaps.fttype = ''
  1217. this.template.table.getdataListParm.parammaps.enable = ''
  1218. this.template.table.getdataListParm.parammaps.tname = ''
  1219. this.template.table.getdataListParm.parammaps.remark = ''
  1220. this.template.table.getdataListParm.parammaps.source = ''
  1221. this.template.table.getdataListParm.offset = 1
  1222. this.getDateList()
  1223. this.isDetailDialog = false
  1224. },
  1225. // 历史时间
  1226. getDateList() {
  1227. GetDataByName(this.template.getdataDateParm).then(response => {
  1228. console.log('table数据', response.data.list)
  1229. if (response.data.list !== null) {
  1230. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1231. this.getTemplateDialogList()
  1232. } else {
  1233. this.template.table.getdataListParm.parammaps.date = ''
  1234. }
  1235. })
  1236. },
  1237. // 配方记录-模板
  1238. getTemplateDialogList() {
  1239. this.template.table.listLoading = true
  1240. GetDataByName(this.template.table.getdataListParm).then(response => {
  1241. console.log('table数据', response.data.list)
  1242. if (response.data.list !== null) {
  1243. this.template.table.list = response.data.list
  1244. this.template.table.pageNum = response.data.pageNum
  1245. this.template.table.pageSize = response.data.pageSize
  1246. this.template.table.total = response.data.total
  1247. } else {
  1248. this.template.table.list = []
  1249. }
  1250. setTimeout(() => {
  1251. this.template.table.listLoading = false
  1252. }, 100)
  1253. })
  1254. },
  1255. handleDialogSearch() {
  1256. this.template.table.getdataListParm.offset = 1
  1257. this.getTemplateDialogList()
  1258. this.arrowDown = true
  1259. this.arrowUp = false
  1260. },
  1261. handleDialogRefresh() {
  1262. this.template.table.getdataListParm.parammaps.ccname = ''
  1263. this.template.table.getdataListParm.parammaps.fttype = ''
  1264. this.template.table.getdataListParm.parammaps.enable = ''
  1265. this.template.table.getdataListParm.parammaps.tname = ''
  1266. this.template.table.getdataListParm.parammaps.remark = ''
  1267. this.template.table.getdataListParm.parammaps.source = ''
  1268. this.template.table.getdataListParm.offset = 1
  1269. this.getTemplateDialogList()
  1270. },
  1271. // 配方记录-模板行点击
  1272. tableRowClickDialog(row, column, event) {
  1273. console.log('配方记录-模板行点击')
  1274. this.isDetailDialog = true
  1275. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1276. this.getDialogList()
  1277. this.getDownList()
  1278. },
  1279. getDialogList() {
  1280. this.template.table2.listLoading = true
  1281. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1282. console.log('table数据', response.data.list)
  1283. if (response.data.list !== null) {
  1284. this.template.table2.list = response.data.list
  1285. this.template.table2.pageNum = response.data.pageNum
  1286. this.template.table2.pageSize = response.data.pageSize
  1287. this.template.table2.total = response.data.total
  1288. } else {
  1289. this.template.table2.list = []
  1290. }
  1291. setTimeout(() => {
  1292. this.template.table2.listLoading = false
  1293. }, 100)
  1294. })
  1295. },
  1296. handleDialogSearch2() {
  1297. console.log('点击了查询')
  1298. this.arrowDown2 = true
  1299. this.arrowUp2 = false
  1300. this.template.table2.getdataListParm.offset = 1
  1301. this.getDialogList2()
  1302. },
  1303. handleDialogRefresh2() {
  1304. console.log('点击了重置')
  1305. this.template.table2.getdataListParm.parammaps.fname = ''
  1306. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1307. this.template.table2.getdataListParm.parammaps.fweight = ''
  1308. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1309. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1310. this.template.table2.getdataListParm.parammaps.sort = ''
  1311. this.template.table2.getdataListParm.offset = 1
  1312. this.getDialogList2()
  1313. },
  1314. getDialogList2() {
  1315. this.template.table2.listLoading = true
  1316. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1317. console.log('table数据', response.data.list)
  1318. if (response.data.list !== null) {
  1319. this.template.table2.list = response.data.list
  1320. this.template.table2.pageNum = response.data.pageNum
  1321. this.template.table2.pageSize = response.data.pageSize
  1322. this.template.table2.total = response.data.total
  1323. } else {
  1324. this.template.table2.list = []
  1325. }
  1326. this.$nextTick(function() {
  1327. window.scrollTo({
  1328. 'top': this.$refs.templateDialog.clientHeight
  1329. })
  1330. })
  1331. setTimeout(() => {
  1332. this.template.table2.listLoading = false
  1333. }, 100)
  1334. })
  1335. },
  1336. // 历史记录
  1337. handleHistoryRecord() {
  1338. console.log('点击了历史记录,页面待画')
  1339. this.historyRecord.dialogStatus = 'historyRecord'
  1340. this.historyRecord.dialogFormVisible = true
  1341. const vue = this
  1342. var myComponent = () => import('./historyRecord.vue')
  1343. return vue.historyRecord.myComponent = myComponent
  1344. },
  1345. // 导出
  1346. handleExport(item) {
  1347. if (item == 1) {
  1348. console.log('点击了导出模板')
  1349. } else {
  1350. console.log('点击了导出数据')
  1351. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1352. GetDataByName(this.download.getdataListParm).then(response => {
  1353. if (response.data.list !== null) {
  1354. for (let i = 0; i < response.data.list.length; i++) {
  1355. if (response.data.list[i].islockcount == 0) {
  1356. this.$set(response.data.list[i], 'islockcount', '否')
  1357. } else {
  1358. this.$set(response.data.list[i], 'islockcount', '是')
  1359. }
  1360. if (response.data.list[i].enable == 0) {
  1361. this.$set(response.data.list[i], 'enable', '否')
  1362. } else {
  1363. this.$set(response.data.list[i], 'enable', '是')
  1364. }
  1365. }
  1366. this.download.list = response.data.list
  1367. } else {
  1368. this.download.list = []
  1369. }
  1370. var excelDatas = [
  1371. {
  1372. tHeader: ['配方名称', '牲畜类别', '配方类型', '来源', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '顺序'],
  1373. filterVal: ['tname', 'ccname', 'fttype', 'source', 'remark', 'enable', 'feedgroup', 'fname', 'fweight', 'autosecond', 'islockcount', 'sort'],
  1374. tableDatas: this.download.list,
  1375. sheetName: 'Sheet1'
  1376. }
  1377. ]
  1378. json2excel(excelDatas, '配方模板', true, 'xlsx')
  1379. })
  1380. }
  1381. },
  1382. beforeImport(file) {
  1383. const isLt2M = file.size / 1024 / 1024 < 2
  1384. if (!isLt2M) {
  1385. this.$message.error('上传文件大小不能超过 2MB!')
  1386. }
  1387. return isLt2M
  1388. },
  1389. handleImportSuccess(res, file) {
  1390. this.getList()
  1391. if (res.msg === 'ok') {
  1392. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1393. if (res.data.err_count > 0) {
  1394. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1395. import('@/vendor/Export2Excel').then(excel => {
  1396. const list1 = res.data.result
  1397. const tHeader = [
  1398. '配方名称', '牲畜类别', '配方类型', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '错误信息'
  1399. ]
  1400. const filterVal = [
  1401. '配方名称', '牲畜类别', '配方类型', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', 'error_msg'
  1402. ]
  1403. const data1 = this.formatJson(filterVal, list1)
  1404. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '配方模板导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1405. })
  1406. }
  1407. } else {
  1408. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1409. }
  1410. },
  1411. formatJson(filterVal, jsonData) {
  1412. return jsonData.map(v =>
  1413. filterVal.map(j => {
  1414. if (j === 'timestamp') {
  1415. return parseTime(v[j])
  1416. } else {
  1417. return v[j]
  1418. }
  1419. })
  1420. )
  1421. },
  1422. changeDate() {
  1423. this.getTemplateDialogList()
  1424. },
  1425. // 应用
  1426. handleApplication() {
  1427. console.log('点击了应用')
  1428. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1429. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1430. }).then(() => {
  1431. this.requestParam.name = 'applyFTdate'
  1432. this.requestParam.parammaps = {}
  1433. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1434. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1435. PostDataByName(this.requestParam).then(response => {
  1436. if (response.msg === 'fail') {
  1437. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1438. } else {
  1439. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1440. this.getTemplateDialogList()
  1441. this.getList()
  1442. }
  1443. })
  1444. }).catch(() => {
  1445. this.$message({ type: 'info', message: '已取消应用' })
  1446. })
  1447. },
  1448. // 模板行点击
  1449. tableRowClick(row, column, event) {
  1450. console.log(row, column, event)
  1451. for (let i = 0; i < this.table.list.length; i++) {
  1452. if (this.table.list[i].Edit == true) {
  1453. return false
  1454. }
  1455. }
  1456. if (column.label !== '操作') {
  1457. this.isDetail = true // 点击行显示详情
  1458. this.table2.getdataListParm.parammaps.ftid = row.id
  1459. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1460. this.getList2()
  1461. this.getDownList()
  1462. }
  1463. },
  1464. // -------------------详情-----------------------------
  1465. // 获取是否显示是否锁定牛头数
  1466. getIsLockCount() {
  1467. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1468. console.log(response.data.list)
  1469. if (response.data.list[0].inforvalue == 0) {
  1470. this.lockCount.isLockCount = false
  1471. } else {
  1472. this.lockCount.isLockCount = true
  1473. }
  1474. })
  1475. },
  1476. // 详情
  1477. getList2() {
  1478. this.table2.listLoading = true
  1479. GetDataByName(this.table2.getdataListParm).then(response => {
  1480. console.log('table数据', response.data.list)
  1481. if (response.data.list !== null) {
  1482. for (let i = 0; i < response.data.list.length; i++) {
  1483. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1484. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1485. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1486. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1487. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1488. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1489. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1490. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1491. }
  1492. this.table2.list = response.data.list
  1493. this.table2.pageNum = response.data.pageNum
  1494. this.table2.pageSize = response.data.pageSize
  1495. this.table2.total = response.data.total
  1496. this.rowDrop()
  1497. } else {
  1498. this.table2.list = []
  1499. }
  1500. this.$nextTick(function() {
  1501. console.log(this.$refs)
  1502. console.log(this.$refs.template.clientHeight)
  1503. window.scrollTo({
  1504. 'top': this.$refs.template.clientHeight
  1505. })
  1506. })
  1507. setTimeout(() => {
  1508. this.table2.listLoading = false
  1509. }, 100)
  1510. })
  1511. },
  1512. // 行拖拽
  1513. rowDrop() {
  1514. console.log(1111)
  1515. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1516. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1517. // this.sorTable()
  1518. const that = this
  1519. // Sortable.create(tbody, {
  1520. var sortable = Sortable.create(tbody, {
  1521. disabled: that.dropState,
  1522. onChoose({ newIndex, oldIndex }) {
  1523. if (that.dropState == true) {
  1524. sortable.destroy()
  1525. }
  1526. },
  1527. onEnd({ newIndex, oldIndex }) {
  1528. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1529. that.table2.list.splice(newIndex, 0, currRow)
  1530. console.log('索引', newIndex)
  1531. console.log('拖动数据', currRow)
  1532. console.log('上', that.table2.list[newIndex - 1])
  1533. console.log('下', that.table2.list[newIndex + 1])
  1534. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1535. for (let i = 0; i < that.table2.list.length; i++) {
  1536. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1537. }
  1538. currRow.sort = 0
  1539. currRow.feedgroup = currRow.fname
  1540. console.log('拖动至最上方无值')
  1541. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1542. currRow.sort = that.table2.list[newIndex - 1].sort
  1543. console.log('拖动值顺序等于上值顺序')
  1544. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1545. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1546. currRow.feedgroup = currRow.fname
  1547. console.log('拖动至最下方无值')
  1548. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1549. currRow.sort == that.table2.list[newIndex + 1].sort
  1550. console.log('拖动值顺序等于下值顺序')
  1551. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1552. currRow.sort = that.table2.list[newIndex - 1].sort
  1553. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1554. console.log('拖动至上下顺序一致')
  1555. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1556. console.log('上下')
  1557. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1558. console.log(newIndex)
  1559. for (let i = newIndex; i < that.table2.list.length; i++) {
  1560. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1561. }
  1562. }
  1563. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1564. currRow.feedgroup = currRow.fname
  1565. console.log(that.table2.list[newIndex + 1].sort)
  1566. }
  1567. that.requestParam = {}
  1568. that.requestParam.common = { 'returnmap': '0' }
  1569. that.requestParam.data = []
  1570. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1571. that.requestParam.data[0].children = []
  1572. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1573. id: '@insertSpotList.id',
  1574. pastureid: '@insertSpotList.pastureid',
  1575. sort: '@insertSpotList.sort',
  1576. feedgroup: '@insertSpotList.feedgroup'
  1577. }}
  1578. ExecDataByConfig(that.requestParam).then(response => {
  1579. console.log('顺序切换保存发送参数', that.requestParam)
  1580. if (response.msg === 'fail') {
  1581. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1582. } else {
  1583. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1584. that.getList2()
  1585. }
  1586. })
  1587. }
  1588. })
  1589. console.log(sortable.option('disabled'))
  1590. },
  1591. handleSearch2() {
  1592. console.log('点击了查询')
  1593. this.arrowDown2 = true
  1594. this.arrowUp2 = false
  1595. this.table2.getdataListParm.offset = 1
  1596. this.getList2()
  1597. },
  1598. handleRefresh2() {
  1599. console.log('点击了重置')
  1600. this.table2.getdataListParm.parammaps.fname = ''
  1601. this.table2.getdataListParm.parammaps.feedgroup = ''
  1602. this.table2.getdataListParm.parammaps.fweight = ''
  1603. this.table2.getdataListParm.parammaps.autosecondname = ''
  1604. this.table2.getdataListParm.parammaps.islockcount = '0'
  1605. this.table2.getdataListParm.parammaps.sort = ''
  1606. this.table2.getdataListParm.offset = 1
  1607. this.getList2()
  1608. },
  1609. // 详情新增
  1610. handleCreate2() {
  1611. console.log('点击了详情新增', this.table2.list)
  1612. // 编辑true/不可编辑false
  1613. // 新增操true,编辑false,编辑保存false
  1614. console.log(11)
  1615. for (let i = 0; i < this.table2.list.length; i++) {
  1616. if (this.table2.list[i].Edit === true) {
  1617. console.log(123)
  1618. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1619. return false
  1620. }
  1621. }
  1622. console.log(this.table2.list)
  1623. if (this.table2.list.length == 0) {
  1624. var mysort = 0
  1625. } else {
  1626. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1627. }
  1628. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1629. console.log(this.table2.list)
  1630. },
  1631. changeFname(item, row) {
  1632. console.log(item, row)
  1633. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1634. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1635. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1636. this.table2.temp.preftid = '0'
  1637. } else {
  1638. this.table2.temp.preftid = item
  1639. }
  1640. if (row.sort == '') {
  1641. row.feedgroup = this.table2.temp.fname
  1642. } else {
  1643. if (row.isCreate == true) { // 新增状态下
  1644. for (let i = 1; i < this.table2.list.length; i++) {
  1645. if (this.table2.list[i].sort == row.sort) {
  1646. console.log(this.table2.list[i])
  1647. row.feedgroup = this.table2.list[i].feedgroup
  1648. break
  1649. } else {
  1650. row.feedgroup = this.table2.temp.fname
  1651. }
  1652. }
  1653. } else if (row.isUpdateSave == true) { // 编辑状态下
  1654. var Arr = []
  1655. for (let i = 0; i < this.table2.list.length; i++) {
  1656. Arr.push(this.table2.list[i].sort)
  1657. }
  1658. var Count = 0
  1659. for (let i = 0; i < Arr.length; i++) {
  1660. if (Arr[i] == row.sort) {
  1661. Count++
  1662. }
  1663. }
  1664. for (let i = 0; i < this.table2.list.length; i++) {
  1665. if (Count > 1) {
  1666. row.feedgroup = this.table2.list[i].feedgroup
  1667. console.log(111, this.table2.list[i].feedgroup)
  1668. break
  1669. } else if (Count == 1) {
  1670. row.feedgroup = this.table2.temp.fname
  1671. console.log(222, this.table2.temp.fname)
  1672. }
  1673. }
  1674. }
  1675. }
  1676. },
  1677. bort(row) {
  1678. if (row.isCreate == true) {
  1679. if (row.sort !== '') {
  1680. for (let i = 1; i < this.table2.list.length; i++) {
  1681. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1682. row.feedgroup = this.table2.list[i].feedgroup
  1683. return false
  1684. } else {
  1685. row.feedgroup = row.fname
  1686. }
  1687. }
  1688. } else {
  1689. row.feedgroup = row.fname
  1690. }
  1691. } else if (row.isUpdateSave == true) {
  1692. if (row.sort !== '') {
  1693. for (let i = 0; i < this.table2.list.length; i++) {
  1694. if (this.table2.list[i].sort == row.sort) {
  1695. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1696. if (this.table2.list[i].id !== row.id) {
  1697. row.isGroupDisabled = true
  1698. row.feedgroup = this.table2.list[i].feedgroup
  1699. break
  1700. }
  1701. } else {
  1702. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1703. row.isGroupDisabled = true
  1704. row.feedgroup = row.fname
  1705. }
  1706. }
  1707. } else {
  1708. row.feedgroup = row.fname
  1709. }
  1710. }
  1711. },
  1712. createData2(row) {
  1713. console.log('点击了详情新增保存', row)
  1714. this.table2.temp.pastureid = Cookies.get('pastureid')
  1715. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1716. this.table2.temp.fid = row.fid
  1717. this.table2.temp.fname = this.table2.temp.fname
  1718. this.table2.temp.fweight = row.fweight
  1719. this.table2.temp.islockcount = row.islockcount
  1720. this.table2.temp.sort = row.sort
  1721. this.table2.temp.feedgroup = row.feedgroup
  1722. this.table2.temp.preftid = this.table2.temp.preftid
  1723. this.table2.temp.autosecond = row.autosecond
  1724. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1725. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1726. return false
  1727. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1728. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1729. return false
  1730. } else if (this.table2.temp.fid == '') {
  1731. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1732. return false
  1733. } else if (this.table2.temp.fweight == '') {
  1734. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1735. return false
  1736. } else if (this.table2.temp.autosecond == '') {
  1737. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1738. return false
  1739. }
  1740. if (this.table2.temp.sort !== '') {
  1741. this.table2.temp.sort = this.table2.temp.sort
  1742. } else {
  1743. console.log(this.table2.list.length)
  1744. if (this.table2.list.length == 1) {
  1745. this.table2.temp.sort = 0
  1746. } else {
  1747. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1748. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1749. }
  1750. }
  1751. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1752. if (parseInt(this.table2.temp.preftid) > 0) {
  1753. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1754. return false
  1755. }
  1756. }
  1757. // 校验顺序是否>=0
  1758. var ruleSort = /^\d+$/
  1759. if (!ruleSort.test(this.table2.temp.sort)) {
  1760. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1761. return false
  1762. }
  1763. // 检验重量>0
  1764. // this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 2) //根据默认参数设置小数位数
  1765. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1766. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1767. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1768. return false
  1769. }
  1770. this.isokDisable = true
  1771. setTimeout(() => {
  1772. this.isokDisable = false
  1773. }, 1000)
  1774. this.requestParam.common = { 'returnmap': '0' }
  1775. this.requestParam.data = []
  1776. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1777. pastureid: this.table2.temp.pastureid,
  1778. ftid: this.table2.getdataListParm.parammaps.ftid,
  1779. fid: row.fid,
  1780. fname: this.table2.temp.fname,
  1781. fweight: row.fweight,
  1782. islockcount: row.islockcount,
  1783. sort: row.sort,
  1784. feedgroup: row.feedgroup,
  1785. preftid: this.table2.temp.preftid,
  1786. autosecond: row.autosecond
  1787. }}
  1788. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1789. pastureid: this.table2.temp.pastureid,
  1790. ftid: this.table2.getdataListParm.parammaps.ftid,
  1791. type: this.table2.getdataListParm.parammaps.fttypeid
  1792. }}
  1793. ExecDataByConfig(this.requestParam).then(response => {
  1794. console.log('新增保存发送参数', this.requestParam)
  1795. if (response.msg !== 'fail') {
  1796. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1797. this.getList2()
  1798. } else {
  1799. failproccess(response, this.$notify)
  1800. }
  1801. })
  1802. },
  1803. createCancel2(row) {
  1804. console.log('点击了详情新增取消')
  1805. for (let i = 0; i < this.table2.list.length; i++) {
  1806. if (row.myId === this.table2.list[i].myId) {
  1807. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1808. }
  1809. if (listIndex > -1) {
  1810. this.table2.list.splice(listIndex, 1)
  1811. return
  1812. }
  1813. }
  1814. this.getDialogList()
  1815. },
  1816. // 详情编辑
  1817. handleUpdate2(row) {
  1818. console.log('详情编辑', row)
  1819. this.dropState = true
  1820. row.isGroupDisabled = false
  1821. row.islockcount = String(row.islockcount)
  1822. row.fid = String(row.fid)
  1823. row.autosecond = String(row.autosecond)
  1824. this.table2.temp.fname = row.fname
  1825. this.table2.temp.preftid = row.preftid
  1826. const rowArr = []
  1827. for (let i = 0; i < this.table2.list.length; i++) {
  1828. if (this.table2.list[i].Edit == true) {
  1829. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1830. return false
  1831. }
  1832. rowArr.push(this.table2.list[i].sort)
  1833. }
  1834. var count = 0
  1835. for (let i = 0; i < rowArr.length; i++) {
  1836. if (rowArr[i] == row.sort) {
  1837. count++
  1838. }
  1839. }
  1840. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  1841. if (count == 1) {
  1842. // 饲料组编辑false,不可编辑true
  1843. row.groupEdit = false
  1844. row.groupNoEdit = true
  1845. // 编辑true,不可编辑false
  1846. row.Edit = true
  1847. row.NoEdit = false
  1848. // 新增false,编辑false,编辑保存true
  1849. row.isCreate = false
  1850. row.isUpdate = false
  1851. row.isUpdateSave = true
  1852. } else if (count > 1) {
  1853. // 饲料组编辑true,不可编辑false
  1854. row.groupEdit = true
  1855. row.groupNoEdit = false
  1856. console.log(222)
  1857. // 编辑true,不可编辑false
  1858. row.Edit = true
  1859. row.NoEdit = false
  1860. // 新增false,编辑false,编辑保存true
  1861. row.isCreate = false
  1862. row.isUpdate = false
  1863. row.isUpdateSave = true
  1864. return false
  1865. }
  1866. },
  1867. updateData2(row) {
  1868. console.log('点击了详情编辑保存111', row)
  1869. this.isokDisable = true
  1870. setTimeout(() => {
  1871. this.isokDisable = false
  1872. }, 1000)
  1873. this.table2.temp.pastureid = row.pastureid
  1874. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1875. this.table2.temp.fid = row.fid
  1876. this.table2.temp.fname = this.table2.temp.fname
  1877. this.table2.temp.fweight = row.fweight
  1878. this.table2.temp.islockcount = row.islockcount
  1879. this.table2.temp.sort = row.sort
  1880. this.table2.temp.feedgroup = row.feedgroup
  1881. this.table2.temp.preftid = this.table2.temp.preftid
  1882. this.table2.temp.autosecond = row.autosecond
  1883. this.table2.temp.id = row.id
  1884. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1885. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1886. return false
  1887. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1888. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1889. return false
  1890. } else if (this.table2.temp.fid == '') {
  1891. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1892. return false
  1893. } else if (this.table2.temp.fweight == '') {
  1894. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1895. return false
  1896. } else if (this.table2.temp.autosecond == '') {
  1897. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1898. return false
  1899. }
  1900. if (this.table2.temp.sort !== '') {
  1901. this.table2.temp.sort = this.table2.temp.sort
  1902. } else {
  1903. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1904. }
  1905. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1906. if (parseInt(this.table2.temp.preftid) > 0) {
  1907. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1908. return false
  1909. }
  1910. }
  1911. // 校验顺序是否>=0
  1912. var ruleSort = /^\d+$/
  1913. if (!ruleSort.test(this.table2.temp.sort)) {
  1914. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1915. return false
  1916. }
  1917. // this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 2) //根据默认参数设置小数位数
  1918. // 检验重量>0
  1919. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1920. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1921. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1922. return false
  1923. }
  1924. this.requestParam.common = { 'returnmap': '0' }
  1925. this.requestParam.data = []
  1926. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1927. pastureid: row.pastureid,
  1928. ftid: this.table2.getdataListParm.parammaps.ftid,
  1929. fid: row.fid,
  1930. fname: this.table2.temp.fname,
  1931. fweight: row.fweight,
  1932. islockcount: row.islockcount,
  1933. sort: row.sort,
  1934. feedgroup: row.feedgroup,
  1935. preftid: this.table2.temp.preftid,
  1936. autosecond: row.autosecond,
  1937. id: row.id
  1938. }}
  1939. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1940. pastureid: row.pastureid,
  1941. ftid: this.table2.getdataListParm.parammaps.ftid,
  1942. type: this.table2.getdataListParm.parammaps.fttypeid
  1943. }}
  1944. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  1945. pastureid: row.pastureid,
  1946. ftid: this.table2.getdataListParm.parammaps.ftid,
  1947. sort: row.sort,
  1948. feedgroup: row.feedgroup
  1949. }}
  1950. ExecDataByConfig(this.requestParam).then(response => {
  1951. console.log('新增保存发送参数', this.requestParam)
  1952. if (response.msg !== 'fail') {
  1953. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1954. this.getList2()
  1955. this.dropState = false
  1956. } else {
  1957. failproccess(response, this.$notify)
  1958. }
  1959. })
  1960. },
  1961. updateCancel2(row) {
  1962. console.log('点击了详情编辑取消')
  1963. // 饲料组编辑false,不可编辑true
  1964. row.groupEdit = false
  1965. row.groupNoEdit = true
  1966. // 编辑false,不可编辑true
  1967. row.Edit = false
  1968. row.NoEdit = true
  1969. // 新增false,编辑true,编辑保存false
  1970. row.isCreate = false
  1971. row.isUpdate = true
  1972. row.isUpdateSave = false
  1973. this.getList2()
  1974. this.dropState = false
  1975. },
  1976. // 详情删除
  1977. handleRowDelete2(row) {
  1978. console.log('点击了行内删除')
  1979. MessageBox.confirm('是否确认删除此信息?', {
  1980. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1981. }).then(() => {
  1982. this.requestParam.common = { 'returnmap': '0' }
  1983. this.requestParam.data = []
  1984. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1985. pastureid: row.pastureid,
  1986. id: row.id
  1987. }}
  1988. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1989. pastureid: row.pastureid,
  1990. ftid: this.table2.getdataListParm.parammaps.ftid,
  1991. type: this.table2.getdataListParm.parammaps.fttypeid
  1992. }}
  1993. ExecDataByConfig(this.requestParam).then(response => {
  1994. console.log('新增保存发送参数', this.requestParam)
  1995. if (response.msg === 'fail') {
  1996. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1997. } else {
  1998. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1999. this.getList2()
  2000. }
  2001. })
  2002. }).catch(() => {
  2003. this.$message({ type: 'info', message: '已取消删除' })
  2004. })
  2005. },
  2006. handleSelectionChange2(val) {
  2007. console.log('勾选数据', val)
  2008. this.selectList2 = val
  2009. },
  2010. handleDelete2() {
  2011. console.log('点击了删除')
  2012. if (this.selectList2.length == 0) {
  2013. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  2014. } else {
  2015. MessageBox.confirm('是否确认删除此信息?', {
  2016. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2017. }).then(() => {
  2018. console.log(this.selectList)
  2019. this.requestParam.common = { 'returnmap': '0' }
  2020. this.requestParam.data = []
  2021. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2022. this.requestParam.data[0].children = []
  2023. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2024. id: '@insertSpotList.id',
  2025. pastureid: '@insertSpotList.pastureid'
  2026. }}
  2027. ExecDataByConfig(this.requestParam).then(response => {
  2028. console.log('删除保存发送参数', this.requestParam)
  2029. if (response.msg === 'fail') {
  2030. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2031. } else {
  2032. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  2033. this.getList2()
  2034. }
  2035. })
  2036. })
  2037. }
  2038. },
  2039. // 拆分预混料
  2040. handleSplitPremix(row) {
  2041. console.log('点击了拆分预混料')
  2042. MessageBox.confirm('是否确认拆分当前预混料?', {
  2043. confirmButtonText: '确认',
  2044. cancelButtonText: '取消',
  2045. type: 'warning'
  2046. }).then(() => {
  2047. this.requestParam.name = 'splitFTpre'
  2048. this.requestParam.parammaps = {}
  2049. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  2050. this.requestParam.parammaps.preftid = row.preftid
  2051. this.requestParam.parammaps.ftdid = row.id
  2052. this.requestParam.parammaps.pastureid = row.pastureid
  2053. this.requestParam.parammaps.feedgroup = row.feedgroup
  2054. this.requestParam.parammaps.sort = row.sort
  2055. this.requestParam.parammaps.fweight = row.fweight
  2056. PostDataByName(this.requestParam).then(response => {
  2057. if (response.msg === 'fail') {
  2058. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2059. } else {
  2060. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2061. this.getList2()
  2062. }
  2063. })
  2064. }).catch(() => {
  2065. this.$message({
  2066. type: 'info',
  2067. message: '已取消删除'
  2068. })
  2069. })
  2070. },
  2071. // 合成预混料
  2072. handleSyntheticPremix() {
  2073. console.log('点击了合成预混料', this.selectList2)
  2074. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2075. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  2076. return false
  2077. } else {
  2078. if (this.selectList2.length > 1) {
  2079. for (let i = 0; i < this.selectList2.length; i++) {
  2080. if (parseInt(this.selectList2[i].preftid) > 0) {
  2081. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  2082. return false
  2083. }
  2084. }
  2085. if (this.selectList2[0].splitftpreid !== undefined) {
  2086. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  2087. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  2088. GetDataByName(this.detail.getdataListParm).then(response => {
  2089. if (response.data.list !== null) { // 不为空时得到比对数据
  2090. this.detail.list3 = response.data.list
  2091. const sortList = [] // 声明排序数组
  2092. var fweightSum = 0 // 总重量
  2093. for (let i = 0; i < this.selectList2.length; i++) {
  2094. const obj = {}
  2095. obj.fid = this.selectList2[i].fid
  2096. obj.fweight = this.selectList2[i].fweight
  2097. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  2098. sortList.push(obj)
  2099. }
  2100. // 排序
  2101. sortList.sort(function(a, b) {
  2102. return a.fid.localeCompare(b.fid)
  2103. })
  2104. var a = 0
  2105. if (this.detail.list3.length == sortList.length) {
  2106. for (let i = 0; i < this.detail.list3.length; i++) {
  2107. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  2108. a++
  2109. }
  2110. }
  2111. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  2112. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  2113. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  2114. GetDataByName(this.detail.getdataListParm2).then(response => {
  2115. if (response.data.list !== null) {
  2116. this.detail.dialogStatus = 'SyntheticPremix'
  2117. this.detail.dialogFormVisible = true
  2118. this.detail.list = this.selectList2
  2119. this.detail.list2 = response.data.list
  2120. this.detail.disabled = true
  2121. setTimeout(() => {
  2122. this.detail.listLoading = false
  2123. }, 100)
  2124. } else {
  2125. this.detail.list2 = []
  2126. }
  2127. })
  2128. } else {
  2129. this.detail.dialogStatus = 'SyntheticPremix'
  2130. this.detail.dialogFormVisible = true
  2131. this.detail.list = this.selectList2
  2132. this.detail.disabled = false
  2133. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2134. setTimeout(() => {
  2135. this.detail.listLoading = false
  2136. }, 100)
  2137. }
  2138. } else {
  2139. this.detail.dialogStatus = 'SyntheticPremix'
  2140. this.detail.dialogFormVisible = true
  2141. this.detail.list = this.selectList2
  2142. this.detail.disabled = false
  2143. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2144. setTimeout(() => {
  2145. this.detail.listLoading = false
  2146. }, 100)
  2147. }
  2148. } else {
  2149. this.detail.list3 = []
  2150. this.detail.dialogStatus = 'SyntheticPremix'
  2151. this.detail.dialogFormVisible = true
  2152. this.detail.list = this.selectList2
  2153. this.detail.disabled = false
  2154. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2155. setTimeout(() => {
  2156. this.detail.listLoading = false
  2157. }, 100)
  2158. }
  2159. })
  2160. } else {
  2161. this.detail.dialogStatus = 'SyntheticPremix'
  2162. this.detail.dialogFormVisible = true
  2163. this.detail.list = this.selectList2
  2164. this.detail.disabled = false
  2165. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2166. setTimeout(() => {
  2167. this.detail.listLoading = false
  2168. }, 100)
  2169. }
  2170. } else {
  2171. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  2172. return false
  2173. }
  2174. }
  2175. },
  2176. // 畜生类别
  2177. changeLivestockType2(item) {
  2178. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  2179. },
  2180. syntheticPremixData() {
  2181. console.log('点击了合成预混料确认')
  2182. if (this.detail.disabled == true) { // 原预混料
  2183. let sumFweight = 0
  2184. for (let i = 0; i < this.detail.list.length; i++) {
  2185. sumFweight += parseFloat(this.detail.list[i].fweight)
  2186. }
  2187. sumFweight = sumFweight.toFixed(2)
  2188. this.isokDisable = true
  2189. setTimeout(() => {
  2190. this.isokDisable = false
  2191. }, 1000)
  2192. this.requestParam.common = { 'returnmap': '0' }
  2193. this.requestParam.data = []
  2194. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2195. this.requestParam.data[0].children = []
  2196. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2197. pastureid: '@insertSpotList.pastureid',
  2198. id: '@insertSpotList.id'
  2199. }}
  2200. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2201. this.requestParam.data[1].children = []
  2202. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2203. pastureid: Cookies.get('pastureid'),
  2204. ftid: this.table2.getdataListParm.parammaps.ftid,
  2205. fid: this.detail.list2[0].id,
  2206. fname: '@insertSpotList2.tname',
  2207. fweight: sumFweight,
  2208. islockcount: '0',
  2209. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2210. feedgroup: '@insertSpotList2.tname',
  2211. preftid: this.detail.list2[0].id,
  2212. autosecond: this.detail.list[0].autosecond
  2213. }}
  2214. ExecDataByConfig(this.requestParam).then(response => {
  2215. console.log('合成预混料保存发送参数', this.requestParam)
  2216. if (response.msg === 'fail') {
  2217. const tname = new RegExp("key 'tname'")
  2218. if (tname.test(response.data)) {
  2219. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2220. } else {
  2221. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2222. }
  2223. } else {
  2224. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2225. this.detail.dialogFormVisible = false
  2226. this.getList()
  2227. this.getList2()
  2228. this.getDownList()
  2229. }
  2230. })
  2231. } else { // 现生成预混料
  2232. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2233. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2234. return false
  2235. } else if (this.detail.list2[0].tname == '') {
  2236. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2237. return false
  2238. } else if (this.detail.list2[0].ccid == '') {
  2239. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2240. return false
  2241. }
  2242. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2243. if (pattern.test(this.detail.list2[0].tname)) {
  2244. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2245. return false
  2246. }
  2247. let sumFweight = 0
  2248. for (let i = 0; i < this.detail.list.length; i++) {
  2249. sumFweight += parseFloat(this.detail.list[i].fweight)
  2250. }
  2251. sumFweight = sumFweight.toFixed(2)
  2252. console.log(sumFweight)
  2253. this.isokDisable = true
  2254. setTimeout(() => {
  2255. this.isokDisable = false
  2256. }, 1000)
  2257. if (this.detail.list2[0].tcolor == null) {
  2258. this.detail.list2[0].tcolor = '#CCCCCC'
  2259. }
  2260. this.requestParam.common = { 'returnmap': '0' }
  2261. this.requestParam.data = []
  2262. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2263. pastureid: Cookies.get('pastureid'),
  2264. tcode: this.detail.list2[0].tcode,
  2265. tname: this.detail.list2[0].tname,
  2266. tcolor: this.detail.list2[0].tcolor,
  2267. ccid: this.detail.list2[0].ccid,
  2268. ccname: this.detail.list2[0].ccname,
  2269. fttype: this.detail.list2[0].fttype,
  2270. fttypeid: this.detail.list2[0].fttypeid,
  2271. source: this.detail.list2[0].source,
  2272. remark: this.detail.list2[0].remark,
  2273. enable: this.detail.list2[0].enable
  2274. }}
  2275. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2276. this.requestParam.data[1].children = []
  2277. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2278. pastureid: '@insertSpotList.pastureid',
  2279. ftid: '@insertFT.LastInsertId',
  2280. fid: '@insertSpotList.fid',
  2281. fname: '@insertSpotList.fname',
  2282. fweight: '@insertSpotList.fweight',
  2283. islockcount: '@insertSpotList.islockcount',
  2284. sort: '@insertSpotList.sort',
  2285. feedgroup: '@insertSpotList.feedgroup',
  2286. preftid: '@insertSpotList.preftid',
  2287. autosecond: '@insertSpotList.autosecond'
  2288. }}
  2289. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2290. pastureid: '@insertSpotList.pastureid',
  2291. id: '@insertSpotList.id'
  2292. }}
  2293. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2294. this.requestParam.data[2].children = []
  2295. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2296. pastureid: Cookies.get('pastureid'),
  2297. ftid: this.table2.getdataListParm.parammaps.ftid,
  2298. fid: '@insertFT.LastInsertId',
  2299. fname: '@insertSpotList2.tname',
  2300. fweight: sumFweight,
  2301. islockcount: '0',
  2302. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2303. feedgroup: '@insertSpotList2.tname',
  2304. preftid: '@insertFT.LastInsertId',
  2305. autosecond: this.detail.list[0].autosecond
  2306. }}
  2307. ExecDataByConfig(this.requestParam).then(response => {
  2308. console.log('合成预混料保存发送参数', this.requestParam)
  2309. if (response.msg === 'fail') {
  2310. const tname = new RegExp("key 'tname'")
  2311. if (tname.test(response.data)) {
  2312. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2313. } else {
  2314. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2315. }
  2316. } else {
  2317. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2318. this.detail.dialogFormVisible = false
  2319. this.getList()
  2320. this.getList2()
  2321. this.getDownList()
  2322. }
  2323. })
  2324. }
  2325. },
  2326. handleFormulationEvaluation(row) {
  2327. console.log(row)
  2328. this.$router.push({ path: '/statisticalAnalysis/FormulationEvaluation', query: { tname: row.tname }})
  2329. this.$router.push({
  2330. name: 'FormulationEvaluation',
  2331. params: {
  2332. tname: row.tname,
  2333. ftid: row.id,
  2334. pastureid: row.pastureid,
  2335. inputDatetime: [new Date('2021-03-01'), new Date('2021-03-30')], // 日期后台待传
  2336. startTime: '2021-03-01',
  2337. stopTime: '2021-03-30'
  2338. }
  2339. })
  2340. }
  2341. }
  2342. }
  2343. </script>
  2344. <style lang="scss" scoped>
  2345. .search{margin-top:10px;}
  2346. .table{margin-top:10px;}
  2347. .table2{margin-top:10px;}
  2348. $width:350px;
  2349. $left:325px;
  2350. .selectInput{
  2351. position: relative;
  2352. display: inline-block;
  2353. .Input{width: $width;position: relative;}
  2354. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2355. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2356. .selectUl{
  2357. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2358. li{
  2359. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2360. a{float:left;width: 80px;}
  2361. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2362. }
  2363. }
  2364. }
  2365. .template{
  2366. background: #fff;
  2367. position: relative;
  2368. }
  2369. .detail{
  2370. background: #fff;
  2371. position: relative;
  2372. }
  2373. .templateDialog{
  2374. background: #fff;
  2375. position: relative;
  2376. }
  2377. .detailDialog{
  2378. background: #fff;
  2379. position: relative;
  2380. }
  2381. </style>